The dechex() function converts a decimal number into a binary number.
PHP dechex() Function has the following format.
string dechex ( int num )
Parameter | Is Required | Description |
---|---|---|
number | Required. | Decimal value to convert |
Item | Description |
---|---|
Return Value | A string that contains the hexadecimal number of the decimal value |
Return Type | String |
To convert hexadecimal to decimal, use the hexdec() function.
Convert decimal to hexadecimal:
<?php
print dechex(232); // "e8"
print "\n";
echo dechex("30") . "\n";
echo dechex("10") . "\n";
echo dechex("1587") . "\n";
echo dechex("70");
?>
The code above generates the following result.