<!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>Creates a new binary data object</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="class.mongobindata.html">MongoBinData</a></div> <div class="next" style="text-align: right; float: right;"><a href="mongobindata.tostring.html">MongoBinData::__toString</a></div> <div class="up"><a href="class.mongobindata.html">MongoBinData</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="mongobindata.construct" class="refentry"> <div class="refnamediv"> <h1 class="refname">MongoBinData::__construct</h1> <p class="verinfo">(PECL mongo >= 0.8.1)</p><p class="refpurpose"><span class="refname">MongoBinData::__construct</span> — <span class="dc-title">Creates a new binary data object</span></p> </div> <div id="mongobindata.construct-soft-deprecation-notice" class="soft-deprecation-notice"> <blockquote class="sidebar"> <p class="para">This extension that defines this method is deprecated. Instead, the <a href="set.mongodb.html" class="link">MongoDB</a> extension should be used. Alternatives to this method include:</p> <ul class="simplelist"> <li class="member"><span class="methodname"><a href="mongodb-bson-binary.construct.html" class="methodname">MongoDB\BSON\Binary::__construct()</a></span></li> </ul> </blockquote> </div> <div class="refsect1 description" id="refsect1-mongobindata.construct-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="methodname"><strong>MongoBinData::__construct</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$type</code><span class="initializer"> = 0</span></span> ] )</div> <p class="para rdfs-comment"> Creates a new binary data object. </p> <p class="para"> There are seven types of binary data currently recognized by the BSON spec, which are defined as <a href="class.mongobindata.html#mongobindata.constants.types" class="link">class constants</a>. For backwards compatibility, the PHP driver uses <strong><code>MongoBinData::BYTE_ARRAY</code></strong> as the default; however, this may change to <strong><code>MongoBinData::GENERIC</code></strong> in the future. Users are encouraged to specify a type instead of relying on the default. </p> </div> <div class="refsect1 parameters" id="refsect1-mongobindata.construct-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <code class="parameter">data</code> </dt> <dd> <p class="para"> Binary data. </p> </dd> <dt> <code class="parameter">type</code> </dt> <dd> <p class="para"> Data type. </p> </dd> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-mongobindata.construct-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns a new binary data object. </p> </div> <div class="refsect1 changelog" id="refsect1-mongobindata.construct-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.5.0</td> <td> The default changed from <em>2</em> (<strong><code>MongoBinData::BYTE_ARRAY</code></strong>) to <em>0</em> (<strong><code>MongoBinData::GENERIC</code></strong>). </td> </tr> <tr> <td>1.2.11</td> <td> Emits <strong><code>E_DEPRECATED</code></strong> when the second argument is not used. The default value for <code class="parameter">type</code> may change in the near future. </td> </tr> </tbody> </table> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="class.mongobindata.html">MongoBinData</a></div> <div class="next" style="text-align: right; float: right;"><a href="mongobindata.tostring.html">MongoBinData::__toString</a></div> <div class="up"><a href="class.mongobindata.html">MongoBinData</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>