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:
- Passing 10 as a parameter:
<?phpecho dechex(10);?>chevron_rightfilter_noneOutput:
a
- Passing 47 as a parameter:
<?phpecho dechex(47);?>chevron_rightfilter_noneOutput:
2f
- When the largest possible decimal number is passed as a parameter:
<?phpecho dechex(4294967295);?>chevron_rightfilter_noneOutput:
ffffffff
Reference:
http://php.net/manual/en/function.dechex.php
Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to get the function name inside a function in PHP ?
- How to get the function name from within that function using JavaScript ?
- D3.js | d3.max() function
- CSS | var() Function
- PHP | each() Function
- PHP | Ds\Map put() Function
- PHP | pow( ) Function
- PHP | Ds\Set xor() Function
- PHP | Ds\Map xor() Function
- CSS | rgb() Function
- PHP | min( ) Function
- PHP | key() Function
- PHP | end() Function
- p5.js | hex() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



