Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 3381

php-manual-en-5.5.7-1.mga4.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>Decodes a hexadecimally encoded binary string</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.hebrevc.html">hebrevc</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.html-entity-decode.html">html_entity_decode</a></div>
 <div class="up"><a href="ref.strings.html">String Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.hex2bin" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">hex2bin</h1>
  <p class="verinfo">(PHP &gt;= 5.4.0)</p><p class="refpurpose"><span class="refname">hex2bin</span> &mdash; <span class="dc-title">Decodes a hexadecimally encoded binary string</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.hex2bin-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>hex2bin</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>
   )</div>

  <p class="para rdfs-comment">
   Decodes a hexadecimally encoded binary string.
  </p>
  <div class="caution"><strong class="caution">Caution</strong>
   <p class="para">
    This function does <em class="emphasis">NOT</em> convert a hexadecimal number to a binary
    number. This can be done using the  <span class="function"><a href="function.base-convert.html" class="function">base_convert()</a></span> function.
   </p>
  </div>
 </div>


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

   <dt>

    <span class="term"><em><code class="parameter">data</code></em></span>
    <dd>

     <p class="para">
      Hexadecimal representation of data.
     </p>
    </dd>

   </dt>

  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.hex2bin-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the binary representation of the given data  or <strong><code>FALSE</code></strong> on failure.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.hex2bin-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="para">
   If the hexadecimal input string is of odd length or invalid hexadecimal string
   an <strong><code>E_WARNING</code></strong> level error is thrown.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.hex2bin-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>5.5.1</td>
       <td>
        A warning is thrown if the input string is invalid hexadecimal string.
       </td>
      </tr>

      <tr>
       <td>5.4.1</td>
       <td>
        A warning is thrown if the input string is of odd length. In PHP 5.4.0 the string
        was silently accepted, but the last byte was truncated.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.hex2bin-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="hex2bin.example.basic">
   <p><strong>Example #1  <span class="function"><strong>hex2bin()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$hex&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">hex2bin</span><span style="color: #007700">(</span><span style="color: #DD0000">"6578616d706c65206865782064617461"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$hex</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>The above example will output
something similar to:</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
string(16) &quot;example hex data&quot;
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.hex2bin-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.bin2hex.html" class="function" rel="rdfs-seeAlso">bin2hex()</a> - Convert binary data into hexadecimal representation</span></li>
    <li class="member"> <span class="function"><a href="function.unpack.html" class="function" rel="rdfs-seeAlso">unpack()</a> - Unpack data from binary string</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.hebrevc.html">hebrevc</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.html-entity-decode.html">html_entity_decode</a></div>
 <div class="up"><a href="ref.strings.html">String Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>