Facebook Page Twitter Page LinkedIn Page
× PHP Tutorial PHP Advanced PHP Resources


The PHP Math hexdec() function returns the decimal number equivalent to the hexadecimal number represented by the hexadecimal string argument.

Syntax

hexdec(hex_string)

Parameters

hex_string Required. Specify the hexadecimal number to convert.

Return Value

The decimal representation of a hexadecimal string argument.

Example:

In the below example, hexdec() function returns the decimal representation of a hexadecimal string argument.

<?php
$x = 'fff'; 
$y = '1ff';
$z = 'eff';

echo "hexdec($x) returns: ".hexdec($x)."\n";
echo "hexdec($y) returns: ".hexdec($y)."\n";
echo "hexdec($z) returns: ".hexdec($z)."\n";
?>

The output of the above code will be:

hexdec(fff) returns: 4095
hexdec(1ff) returns: 511
hexdec(eff) returns: 3839

❮ PHP Math Functions