bin2hex()


string bin2hex ( string $str )

Description

bin2hex() converts a string into a hexadecimal representation

※ available F/W version : all

Parameters

Return values

Returns an ASCII string containing the hexadecimal representation of the given string

Examples

<?php
$str = "ABC abc 012";
hexdump($str); // OUTPUT: 0000 41 42 43 20 61 62 63 20 30 31 32 |ABC abc 012 |

echo bin2hex($str); // OUTPUT: 4142432061626320303132
?>
<?php
$buf = "Hello";

$hex = bin2hex($buf);
echo $buf; // OUTPUT: Hello
echo "\r\n";
echo $hex; // OUTPUT: 48656C6C6F
?>

See also

hex2bin()

Remarks

This function is identical to the PHP group’s bin2hex() function.