PHP Tutorial - PHP dechex() Function






Definition

The dechex() function converts a decimal number into a binary number.

Syntax

PHP dechex() Function has the following format.

string dechex ( int num )

Parameter

ParameterIs RequiredDescription
numberRequired. Decimal value to convert

Return

Item Description
Return Value A string that contains the hexadecimal number of the decimal value
Return Type String




Note

To convert hexadecimal to decimal, use the hexdec() function.

Example

Convert decimal to hexadecimal:


<?php
print dechex(232); // "e8" 
print "\n";
echo dechex("30") . "\n";
echo dechex("10") . "\n";
echo dechex("1587") . "\n";
echo dechex("70");
?>

The code above generates the following result.