hex2bin – PHP String Functions

Syntax :

string hex2bin ( string );

Description :

hex2bin function will converts a string of hexadecimal values to ASCII characters.


Parameter :

  • string – This is a Required parameter. String of hexadecimal values which needs to converted.

Output :

This will returns the ASCII value of hexadecimal characters.


ChangeLog :

[table caption=”” width=”100%” colwidth=”25%|75%” colalign=”left|left”]
Version, Description
PHP 5.5.1 , A warning is thrown if the input string is of odd length.
PHP 5.5.4 , The string was silently accepted but the last byte was truncated.
[/table]


Related articles : bin2hex().


hex2bin – PHP Functions Example 1 :

$strExample = "48692066726f6d207475746f7269616c6d696e65732e6e657421";
echo hex2bin($strExample) . "<br>";

In above example ,We have string of hexadecimal characters “48692066726f6d207475746f7269616c6d696e65732e6e657421”.  So, when we apply hex2bin function. This will string of ASCII value of input string.

Now Output will become –

Hi from tutorialmines.net!


Get complete PHP built in functions list with examples pdf now!


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *