PHP hexdec() Function

Definition and Usage

The hexdec() function returns a decimal number equivalent of a hexadecimal number embedded in a string.

This function returns a a decimal integer, though larger values may result in floats.

Syntax

hexdec ( string $hex_string ) : number

Parameters

Sr.No Parameter & Description
1 hex_string
A decimal number to be converted in equivalent octal representation

Return Values

PHP hexdec() function returns a decimal number.

PHP Version

This function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.

Example

<?php
   $arg='-10';
   $val=hexdec($arg);
   echo "hexdec(" . $arg . ") = " . $val;
?>

Output

This will produce following result −

hexdec(-10) = 16
Updated on: 2026-03-11T23:22:53+05:30

179 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements