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

Binary And Back

<?php

$a = 0b11011_11111;

printf('%b', $a);
print PHP_EOL;
print decbin($a);
print PHP_EOL;

PHP supports a binary format to write integers in the code. The format starts with 0b, followed by 0 and 1, and the optional _ for readability, like any other integer.

To produce back binary numbers, one may use decbin() or printf().

In both cases, the original formatting, binary and underscores, are lost after the linting phase, and cannot be regenerated.

See Also

PHP Features

Last updated: 09 November 2026