mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 05:26:57 +08:00
107 lines
5.1 KiB
HTML
107 lines
5.1 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<title>Returns the BSON representation of a PHP value</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.mongodb.bson-fromphp" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">MongoDB\BSON\fromPHP</h1>
|
|
<p class="verinfo">(mongodb >=1.0.0)</p><p class="refpurpose"><span class="refname">MongoDB\BSON\fromPHP</span> — <span class="dc-title">Returns the BSON representation of a PHP value</span></p>
|
|
|
|
</div>
|
|
|
|
<div class="refsect1 description" id="refsect1-function.mongodb.bson-fromphp-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>MongoDB\BSON\fromPHP</strong></span>
|
|
( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.array-object" class="type array|object">array|object</a></span> <code class="parameter">$value</code></span>
|
|
) : <span class="type">string</span></div>
|
|
|
|
<p class="para rdfs-comment">
|
|
Serializes a PHP array or object (e.g. document) to its
|
|
<a href="https://docs.mongodb.com/manual/reference/bson-types/" class="link external">» BSON</a> representation. The
|
|
returned binary string will describe a BSON document.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.mongodb.bson-fromphp-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">value</code> (<span class="type"><a href="language.pseudo-types.html#language.types.array-object" class="type array|object">array|object</a></span>)</dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
PHP value to be serialized.
|
|
</p>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.mongodb.bson-fromphp-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
The serialized BSON document as a binary string.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 errors" id="refsect1-function.mongodb.bson-fromphp-errors">
|
|
<h3 class="title">错误/异常</h3>
|
|
<ul class="simplelist">
|
|
<li class="member">
|
|
Throws
|
|
<a href="class.mongodb_driver_exception_unexpectedvalueexception.html" class="classname">MongoDB\Driver\Exception\UnexpectedValueException</a> if
|
|
the PHP value cannot be converted to BSON. Possible reasons include, but are
|
|
not limited to, encountering an unexpected
|
|
<span class="interfacename"><a href="class.mongodb_bson_type.html" class="interfacename">MongoDB\BSON\Type</a></span> instance or
|
|
<span class="function"><a href="mongodb_bson_serializable.bsonserialize.html" class="function">MongoDB\BSON\Serializable::bsonSerialize()</a></span> failing to
|
|
return an <span class="type"><a href="language.types.array.html" class="type array">array</a></span> or <strong class="classname">stdClass</strong>.
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.mongodb.bson-fromphp-examples">
|
|
<h3 class="title">范例</h3>
|
|
<div class="example" id="example-1705">
|
|
<p><strong>Example #1 <span class="function"><strong>MongoDB\BSON\fromPHP()</strong></span> example</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br /><br />$bson </span><span style="color: #007700">= </span><span style="color: #0000BB">MongoDB</span><span style="color: #007700">\</span><span style="color: #0000BB">BSON</span><span style="color: #007700">\</span><span style="color: #0000BB">fromPHP</span><span style="color: #007700">([</span><span style="color: #DD0000">'foo' </span><span style="color: #007700">=> </span><span style="color: #0000BB">1</span><span style="color: #007700">]);<br />echo </span><span style="color: #0000BB">bin2hex</span><span style="color: #007700">(</span><span style="color: #0000BB">$bson</span><span style="color: #007700">), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
<div class="example-contents"><p>以上例程会输出:</p></div>
|
|
<div class="example-contents screen">
|
|
<div class="cdata"><pre>
|
|
0e00000010666f6f000100000000cat
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.mongodb.bson-fromphp-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<ul class="simplelist">
|
|
<li class="member"><span class="function"><a href="mongodb.bson_tophp.html" class="function" rel="rdfs-seeAlso">MongoDB\BSON\toPHP()</a> - Returns the PHP representation of a BSON value</span></li>
|
|
<li class="member"><a href="https://docs.mongodb.com/manual/reference/bson-types/" class="link external">» MongoDB BSON</a></li>
|
|
<li class="member"><a href="mongodb.persistence.html" class="xref">Persisting Data</a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
|
|
</div></div></div></body></html> |