Table of Contents

Syntax

string bin2hex(int $val)

(PHP 4, PHP 5)

$val The integer (long) number to convert to hexadecimal
RETURNS Returns a hexadecimal string converted from the argument

What it Does

Converts binary data into a hexadecimal string equivalent. Hexadecimal is a base 16 numbering system with digits from 0 - 9 A - F. The number 31 in hexadecimal would be 1F which is sometimes represented as 0x1F or 1FH.

Example

echo bin2hex(31);

Outputs:

1f