hexdec()
hexdec() — Hexadecimal to decimal.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
Returns the decimal equivalent of the hexadecimal number represented by the hex_string argument. hexdec() converts a hexadecimal string to a decimal number.
Signature
hexdec(string $hex_string): int|float
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $hex_string | string | The hexadecimal string to convert |
Return value
The decimal representation of hex_string
Example
A runnable snippet:
var_dump(hexdec("ee")); // prints "int(238)" var_dump(hexdec("a0")); // prints "int(160)"
Changelog
| Version | Change |
|---|---|
| 7.4.0 | Passing invalid characters will now generate a deprecation notice. The result will still be computed as if the invalid characters did not exist. |
See also
dechex(), bindec(), octdec(), base_convert()
All PHP 8.5 built-in functions
Reference card built from the PHP manual page hexdec() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.