Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Hexadecimal Integer

Hexadecimal integers are integers with an hexadecimal representation. Their value is the same, yet their are written in a different way than the common decimal.

Hexadecimal has native support with the 0x123 format. There is also support for hexadecimal characters, inside double-quote strings, with the \xhh syntax.

There are functions to convert from and to hexadecimal format: hexdec(), dechex() and base_convert(), from ten to sixteen, and then, with an arbitrary base, up to 36.

PHP also has special syntax for binary and octal numbers.

<?php

    $twenty    = 0x14;
    $twentyToo = 20;
    
    $i = "\x69"; // i is the 105 ASCII code
    $i = 'i';

?>

Documentation

See Also