PHP Tutorial PHP Advanced PHP Resources
Python Java C++ C C# PHP R SQL DS Algo InterviewQ

PHP - Math dechex() Function

The PHP Math dechex() function returns a string which is the hexadecimal representation of a decimal number.




number Required. Specify the decimal number to convert.

Return Value

Hexadecimal string representation of a decimal number.


In the example below, dechex() function returns the hexadecimal string representation of a given decimal number.

$x = 100; 
$y = 500;
$z = 1000;

echo "dechex($x) returns: ".dechex($x)."\n";
echo "dechex($y) returns: ".dechex($y)."\n";
echo "dechex($z) returns: ".dechex($z)."\n";

The output of the above code will be:

dechex(100) returns: 64
dechex(500) returns: 1f4
dechex(1000) returns: 3e8

❮ PHP Math Functions