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 formating, binary and underscores, are lost after the linting phase, and cannot be regenerated.
See Also¶
Binary and back [Try me]
PHP Features¶
Last updated: 04 August 2026