Skip to content
Related Articles

Related Articles

PHP | dechex( ) Function

Improve Article
Save Article
Like Article
  • Last Updated : 09 Mar, 2018

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”.


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.


Input : dechex(10)
Output : a

Input : dechex(47)
Output : 2f

Input : dechex(4294967295)
Output : ffffffff

Below programs illustrate dechex() function in PHP:

  • Passing 10 as a parameter:

    echo dechex(10);


  • Passing 47 as a parameter:

    echo dechex(47);


  • When the largest possible decimal number is passed as a parameter:

    echo dechex(4294967295);




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!