YouTip LogoYouTip

Func String Bin2Hex

# PHP bin2hex() Function [![Image 3: PHP String Reference](#) PHP String Reference](#) ## Example Convert "Hello World!" to a hexadecimal value: [Run Example Β»](#) * * * ## Definition and Usage The bin2hex() function converts a string of ASCII characters to hexadecimal values. The string can be converted back using the pack() function. * * * ## Syntax bin2hex(_string_) | Parameter | Description | | --- | --- | | _string_ | Required. Specifies the string to convert. | ## Technical Details | Return Value: | Returns the hexadecimal value of the string to be converted. | | :--- | | PHP Version: | 4+ | * * * ## More Examples ## Example 1 Convert a string value from binary to hexadecimal and back again: <?php $str = "Hello world!"; echo bin2hex($str) . "
"; echo pack("H*",bin2hex($str)) . "
"; ?> [Run Example Β»](#) * * PHP String Reference](#)
← Func String ChopFunc Mysqli Stat β†’