hexdec() converts a hexadecimal string to its decimal value.
$hex = '2f';
echo hexdec($hex); // 47
Start with this current pattern. The examples below are retained for additional variations, output and reference.
<?Php
echo hexdec('2e'); // Output 46
echo "<br>";
echo hexdec('2ch'); // Output 44
echo "<br>";
echo hexdec('fab'); // Output is 4011
echo "<br>";
echo hexdec('FFFFFF'); // Output is 16777215
?>
Syntax
string hexdec(string $hex);
| Parameter | DESCRIPTION |
|---|---|
| $hex | Required : $hex string to convert to equivalent decimal number. |
$hex = "FF";
echo hexdec($hex); // Output: 255
$hex = "7FFFFFFF";
echo hexdec($hex); // Output: 2147483647
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.