PHP bin2hex() Function
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