hexdec():decimal equivalent of hexadeciam number

<?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);
ParameterDESCRIPTION
$hexRequired : $hex string to convert to equivalent decimal number.
The output is decimal number.
Hexadecimal is positional numeral system with base of 16. The chars it used are from 0 to 9 and from A to F.

Before using hexdec() to convert hexadecimal to decimal system, we can check hexadecimal input string for a valid hexadecimal number or not by using ctype_xdigit.php function.

Here is Demo of checking and converting Hexadecimal input to decimal base number.

DEMO




Example: Converting Hex Color Codes to Decimal

$hex = "FF";
echo hexdec($hex);  // Output: 255

Example: Handling Large Hexadecimal Values

$hex = "7FFFFFFF";
echo hexdec($hex);  // Output: 2147483647

Math Functions dechex(): Convert decimal number to hexadecimal system
base_convert(): Convert number From any base to other decbin() Binary equivalent of decimal number
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com











PHP video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer