PHP.nl

dechex

dechex

Decimal to hexadecimal

string **dechex** int $num

Returns a string containing a hexadecimal representation of the given unsigned argument. num

The largest number that can be converted is (or ): on 32-bit platforms, this will be in decimal, which results in returning . PHP_INT_MAX``* 2 + 1``-1``4294967295``dechex``ffffffff

numThe decimal value to convert.

   As PHP's  type is signed, but
    deals with unsigned integers, negative
   integers will be treated as though they were unsigned.
  `int``dechex`

Hexadecimal string representation of . num

Voorbeeld: example

<?php
echo dechex(10) . "\n";
echo dechex(47);
?>
a
2f

Voorbeeld: example with large integers

<?php
// The output below assumes a 32-bit platform.
// Note that the output is the same for all values.
echo dechex(-1)."\n";
echo dechex(PHP_INT_MAX * 2 + 1)."\n";
echo dechex(pow(2, 32) - 1)."\n";
?>
ffffffff
ffffffff
ffffffff

hexdec``decbin``decoct``base_convert