PHP dechex() Function

Definition and Usage

The dechex() function returns a string that contains hexadecimal equivalent of given decimal number argument.

This function returns a string with hexadecimal characters.

Syntax

dechex ( int $number ) : string

Parameters

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

Return Values

PHP dechex() function returns a hexadecimal number inside string.

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=dechex($arg);
   echo "dechex(" . $arg . ") = " . $val;
?>

Output

This will produce following result −

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

240 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements