decbin()

Published Jul 8, 2023
Contribute to Docs

The decbin() function converts a decimal number to a string containing a binary number.

Syntax

decbin(number);

Where number is the decimal value to be converted to binary. The result returns a string that contains the binary number of the passed decimal value.

Example

<?php
echo decbin(333);
?>

This will result in the following output:

101001101

All contributors

Looking to contribute?

Learn PHP on Codecademy