PHP hexdec() Function

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

ParameterIs RequiredDescription
hex_stringRequired. Specifies the hexadecimal string to convert

Return

ItemDesscription
Return Value The decimal value of hex_string
Return Type Float / Integer

Example

Convert hexadecimal to decimal:


<?php//w  w  w . j ava  2 s.  c  om
echo hexdec("1e") . "\n";
echo hexdec("a") . "\n";
echo hexdec("11ff") . "\n";
echo hexdec("cceeff");
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions