Open In App

PHP dechex( ) Function

The dechex() is a built-in function in PHP and is used to convert a given decimal number to an equivalent hexadecimal number. The word ‘dechex’ in the name of function stands for decimal to hexadecimal. The dechex() function works only with unsigned numbers. If the argument passed to it is negative then it will treat it as an unsigned number.
The largest number that can be converted is 4294967295 in decimal resulting to “ffffffff”.

Syntax:



string dechex($value)

Parameters: This function accepts a single parameter $value. It is the decimal number you want to convert in hexadecimal representation.

Return Value: It returns the hexadecimal string representation of number passed to it as argument.



Examples:

Input : dechex(10)
Output : a

Input : dechex(47)
Output : 2f

Input : dechex(4294967295)
Output : ffffffff

Below programs illustrate dechex() function in PHP:

Reference:
http://php.net/manual/en/function.dechex.php


Article Tags :