hex2bin()
Published May 12, 2023Updated Jun 22, 2023
Contribute to Docs
The hex2bin()
function converts a string
of hexadecimal values to its binary representation.
Note: This function does NOT convert a hexadecimal number to a binary number. The
hex2bin()
function is available only in PHP 5.4.0 and later versions.
Syntax
hex2bin(hex_string);
The hex_string
parameter represents the string
of hexadecimal values to be converted.
Example
The following example uses the hex2bin()
function to convert "504850"
, a string
of hexadecimal values, to a string
. Then the echo
command prints this string
to the console:
<?phpecho hex2bin("504850");?>
The example will result in the following output:
PHP
Codebyte Example
The following example is runnable and uses the hex2bin()
function:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.