PHP hexdec() Function
Example
Convert hexadecimal to decimal:
<?php
echo hexdec("1e") . "<br>";
echo hexdec("a") . "<br>";
echo hexdec("11ff") . "<br>";
echo hexdec("cceeff");
?>
Try it Yourself »
Definition and Usage
The hexdec() function converts a hexadecimal number to a decimal number.
Tip: To convert decimal to hexadecimal, look at the dechex() function.
Syntax
hexdec(hex_string);
Parameter Values
Parameter | Description |
---|---|
hex_string | Required. Specifies the hexadecimal string to convert |
Technical Details
Return Value: | The decimal value of hex_string |
---|---|
Return Type: | Float / Integer |
PHP Version: | 4+ |
❮ PHP Math Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.