w3resource

PHP: hexdec() function

Description

The hexdec() function is used to convert a hexadecimal number to a decimal number.

Version:

(PHP 4 and above)

Syntax:

hexdec(num)

Parameter:

Name Description Required /
Optional
Type
num The hexadecimal string to convert. Required String

Return value:

The decimal representation of num.

Value Type: Integer/Float.

Pictorial Presentation

php math hexdec() function

Example:

<?php
echo hexdec("1f")."<br>";
echo hexdec("b")."<br>";
echo hexdec("11aa")."<br>";
echo hexdec("aaccee");
?> 

Output:

31
11
4522
11193582 

View the example in the browser

See also

PHP Function Reference

Previous: getrandmax
Next: hypot



Follow us on Facebook and Twitter for latest update.