php-doc-en/reference/strings/functions/hex2bin.xml

140 lines
3.2 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.hex2bin" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>hex2bin</refname>
<refpurpose>Decodes a hexadecimally encoded binary string</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>hex2bin</methodname>
<methodparam><type>string</type><parameter>data</parameter></methodparam>
</methodsynopsis>
<para>
Decodes a hexadecimally encoded binary string.
</para>
<caution>
<para>
This function does <emphasis>NOT</emphasis> convert a hexadecimal number to a binary
number. This can be done using the <function>base_convert</function> function.
</para>
</caution>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>data</parameter></term>
<listitem>
<para>
Hexadecimal representation of data.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the binary representation of the given data &return.falseforfailure;.
</para>
</refsect1>
<refsect1 role="errors">
&reftitle.errors;
<para>
If the hexadecimal input string is of odd length or invalid hexadecimal string
an <constant>E_WARNING</constant> level error is thrown.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>5.5.1</entry>
<entry>
A warning is thrown if the input string is invalid hexadecimal string.
</entry>
</row>
<row>
<entry>5.4.1</entry>
<entry>
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.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example xml:id="hex2bin.example.basic">
<title><function>hex2bin</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$hex = hex2bin("6578616d706c65206865782064617461");
var_dump($hex);
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
string(16) "example hex data"
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>bin2hex</function></member>
<member><function>unpack</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->