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//from  w w w  . j  ava  2  s  .co  m
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.





















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