PHP hexdec() Function
In this chapter you will learn:
- Definition for PHP hexdec() Function
- Syntax for PHP hexdec() Function
- Parameter for PHP hexdec() Function
- Return for PHP hexdec() Function
- Example - Convert hexadecimal to decimal
Definition
The hexdec()
function converts a hexadecimal number to a decimal number.
To convert decimal to hexadecimal, use dechex()
function.
Syntax
PHP hexdec() Function has the following syntax.
hexdec(hex_string);
Parameter
Parameter | Is Required | Description |
---|---|---|
hex_string | Required. | Specifies the hexadecimal string to convert |
Return
Item | Desscription |
---|---|
Return Value | The decimal value of hex_string |
Return Type | Float / Integer |
Example
Convert hexadecimal to decimal:
<?php/*from ja v a2 s . c o m*/
echo hexdec("1e") . "\n";
echo hexdec("a") . "\n";
echo hexdec("11ff") . "\n";
echo hexdec("cceeff");
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP hypot() Function
- Syntax for PHP hypot() Function
- Parameter for PHP hypot() Function
- Return for PHP hypot() Function
- Note for PHP hypot() Function
- Example - Calculate the hypotenuse of different right-angle triangles
Home » PHP Tutorial » PHP Math Functions