PHP: dechex() function
Description
The dechex() function is used to convert a decimal number to a hexadecimal number.
Version:
(PHP 4 and above)
Syntax:
dechex(num)
Parameter:
Name | Description | Required / Optional |
Type |
---|---|---|---|
num | The decimal number to convert. | Required | Integer |
Return value:
Hexadecimal string representation of num.
Value Type: String.
Pictorial Presentation
Example:
<?php
$val1= 120;
$val2=7;
$val3=9899;
$zhexa1=dechex($val1);
$zhexa2=dechex($val2);
$zhexa3=dechex($val3);
echo "Hexa value of $val1 is $zhexa1<br />";
echo "Hexa value of $val2 is $zhexa2<br />";
echo "Hexa value of $val3 is $zhexa3<br />";
?>
Output:
Hexa value of 120 is 78 Hexa value of 7 is 7 Hexa value of 9899 is 26ab
See also
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/php/function-reference/dechex.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics