Home >>PHP Math Functions >PHP hexdec() Function
PHP hexdec() function is used to convert a given hexadecimal number in to a decimal number. It converts the numbers that are too large to fit into the integer type. It ignores the non-hexadecimal characters. It accepts only a single parameter $number which is the hexadecimal number whose decimal equivalent is to be calculated. It returns the decimal equivalent of the given hexadecimal number.
Syntax:
hexdec($number);
Parameter | Description |
---|---|
number | This is a required parameter. This parameter defines the hexadecimal string to convert. |
Here is an example of hexdec() function in PHP:
<html> <body> <?php echo hexdec("c")."<br>"; echo hexdec("37")."<br>"; ?> </body> </html>
Here is an another example of hexdec() function in PHP:
<html> <body> <?php echo hexdec("2")."<br>"; echo hexdec("1b")."<br>"; echo hexdec("33")."<br>"; echo hexdec("4d")."<br>"; echo hexdec("233")."<br>"; ?> </body> </html>