PHP hexdec() Function
Definition
The hexdec()
function converts a hexadecimal number to a decimal number.
To convert decimal to hexadecimal, use dechex()
function.
Syntax
PHP hexdec() Function has the following syntax.
hexdec(hex_string);
Parameter
Parameter | Is Required | Description |
---|---|---|
hex_string | Required. | Specifies the hexadecimal string to convert |
Return
Item | Desscription |
---|---|
Return Value | The decimal value of hex_string |
Return Type | Float / Integer |
Example
Convert hexadecimal to decimal:
<?php//w w w . j ava 2 s. c om
echo hexdec("1e") . "\n";
echo hexdec("a") . "\n";
echo hexdec("11ff") . "\n";
echo hexdec("cceeff");
?>
The code above generates the following result.