Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP bin2hex() Function

PHP bin2hex() Function

PHP String Reference Manual PHP String Reference Manual

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

)

Parameters Description
string Required. Specifies the string to convert.

Technical Details

Return Value: Returns the hexadecimal value of the string to convert.
PHP Version: 4+

More examples

Example 1

Convert a string value from binary to hexadecimal and back:

"; echo pack("H*",bin2hex($str)) . "
"; ?>

Run Example »


PHP String Reference Manual PHP String Reference Manual