Sophie

Sophie

distrib > Mageia > 7 > aarch64 > by-pkgid > 2b917e0437961edec048f1d15e2d7449 > files > 4755

php-manual-en-7.2.11-1.mga7.noarch.rpm

<!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 PHP representation of a BSON value</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.mongodb.bson-tojson.html">MongoDB\BSON\toJSON</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.mongodb.bson-torelaxedextendedjson.html">MongoDB\BSON\toRelaxedExtendedJSON</a></div>
 <div class="up"><a href="ref.bson.functions.html">Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.mongodb.bson-tophp" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB\BSON\toPHP</h1>
  <p class="verinfo">(mongodb &gt;=1.0.0)</p><p class="refpurpose"><span class="refname">MongoDB\BSON\toPHP</span> &mdash; <span class="dc-title">Returns the PHP representation of a BSON value</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.mongodb.bson-tophp-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><span class="type array|object">array|object</span></span> <span class="methodname"><strong>MongoDB\BSON\toPHP</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$bson</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$typeMap</code><span class="initializer"> = array()</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   Unserializes a BSON document (i.e. binary string) to its PHP representation.
   The <code class="parameter">typeMap</code> paramater may be used to control the PHP
   types used for converting BSON arrays and documents (both root and embedded).
  </p>
  <div class="warning"><strong class="warning">Warning</strong>
   <p class="simpara">
    Fields containing deprecated BSON types (i.e. undefined, symbol,
    DBPointer) are represented only by bare-bones objects of the classes
    <a href="class.mongodb-bson-undefined.html" class="classname">MongoDB\BSON\Undefined</a>,
    <a href="class.mongodb-bson-symbol.html" class="classname">MongoDB\BSON\Symbol</a>, and
    <a href="class.mongodb-bson-dbpointer.html" class="classname">MongoDB\BSON\DBPointer</a>, when converting BSON to
    PHP. These objects are created from BSON data and used for storing these
    types back into the database, but can not be instantiated as they have a
    private constructor.
   </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.mongodb.bson-tophp-parameters">
  <h3 class="title">Parameters</h3>
  <dl>

   
    <dt>
<code class="parameter">bson</code> (<span class="type"><a href="language.types.string.html" class="type string">string</a></span>)</dt>

    <dd>

     <p class="para">
      BSON value to be unserialized.
     </p>
    </dd>

   
   
   
    <dt>
<code class="parameter">typeMap</code> (<span class="type"><a href="language.types.array.html" class="type array">array</a></span>)</dt>

    <dd>

     <p class="para">
      <a href="mongodb.persistence.deserialization.html#mongodb.persistence.typemaps" class="link">Type map configuration</a>.
     </p>
    </dd>

   

  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.mongodb.bson-tophp-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   The unserialized PHP value.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.mongodb.bson-tophp-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <ul class="simplelist">
   <li class="member">
    Throws
    <a href="class.mongodb-driver-exception-invalidargumentexception.html" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a> if
    a class in the type map cannot be instantiated or does not implement
    <span class="interfacename"><a href="class.mongodb-bson-unserializable.html" class="interfacename">MongoDB\BSON\Unserializable</a></span>.
   </li>
   <li class="member">Throws <a href="class.mongodb-driver-exception-unexpectedvalueexception.html" class="classname">MongoDB\Driver\Exception\UnexpectedValueException</a> if the input did not contain exactly one BSON document. Possible reasons include, but are not limited to, invalid BSON, extra data (after reading one BSON document), or an unexpected <a href="https://github.com/mongodb/libbson" class="link external">&raquo;&nbsp;libbson</a> error.</li>
  </ul>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.mongodb.bson-tophp-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>1.4.0</td>
       <td>
        <p class="para">
         If the input contains an unsupported, deprecated BSON type, the
         driver will now no longer log a warning to the debug log, but instead
         will create an object representing this type.
        </p>
       </td>
      </tr>

      <tr>
       <td>1.3.2</td>
       <td>
        <p class="para">
         <a href="class.mongodb-driver-exception-unexpectedvalueexception.html" class="classname">MongoDB\Driver\Exception\UnexpectedValueException</a>
         is no longer thrown if the input contains an unsupported, deprecated
         BSON type. Such types will be ignored (as they were in versions before
         1.3.0), although the driver will now log a warning to the debug log
         (see: <a href="mongodb.configuration.html#ini.mongodb.debug" class="link">mongodb.debug</a>).
        </p>
       </td>
      </tr>

      <tr>
       <td>1.3.0</td>
       <td>
        <p class="para">
         <a href="class.mongodb-driver-exception-unexpectedvalueexception.html" class="classname">MongoDB\Driver\Exception\UnexpectedValueException</a>
         is thrown if the input contains an unsupported, deprecated BSON type.
         Previously, such types were ignored.
        </p>
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.mongodb.bson-tophp-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-1756">
   <p><strong>Example #1 <span class="function"><strong>MongoDB\BSON\toPHP()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$bson&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">hex2bin</span><span style="color: #007700">(</span><span style="color: #DD0000">'0e00000010666f6f000100000000'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$value&nbsp;</span><span style="color: #007700">=&nbsp;</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">toPHP</span><span style="color: #007700">(</span><span style="color: #0000BB">$bson</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$value</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>The above example will output:</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
object(stdClass)#1 (1) {
  [&quot;foo&quot;]=&gt;
  int(1)
}
</pre></div>
   </div>
  </div>
 </div>



 <div class="refsect1 seealso" id="refsect1-function.mongodb.bson-tophp-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="function.mongodb.bson-fromphp.html" class="function" rel="rdfs-seeAlso">MongoDB\BSON\fromPHP()</a> - Returns the BSON representation of a PHP value</span></li>
   <li class="member"><a href="https://docs.mongodb.com/manual/reference/bson-types/" class="link external">&raquo;&nbsp;MongoDB BSON</a></li>
   <li class="member"><a href="mongodb.persistence.html" class="xref">Persisting Data</a></li>
  </ul>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.mongodb.bson-tojson.html">MongoDB\BSON\toJSON</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.mongodb.bson-torelaxedextendedjson.html">MongoDB\BSON\toRelaxedExtendedJSON</a></div>
 <div class="up"><a href="ref.bson.functions.html">Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>