Tutorialsplane

PHP bin2hex Function


PHP bin2hex Function :The string function bin2hex() converts the binary string to hexadecimal string. It accepts parameter as string and returns the hexadecimal.


Syntax for PHP bin2hex function :

bin2hex(string)

Returns : Hexadecimal String

PHP bin2hex Example 1

$string = "11111";
$result = bin2hex($string);
echo $result;

Try it »

PHP bin2hex Function Example

PHP bin2hex Example 2

$string = "Hello world!";
$result = bin2hex($string);
echo $result;

Try it »

PHP bin2hex Example

PHP bin2hex Reverse

$string = "Hello world!";
$result1 = bin2hex($string);
echo $result1."<br/>";
$result2 = pack("H*",$result1);
echo $result2;

Try it »

PHP String Functions