Facebook Page Twitter Page LinkedIn Page
× PHP Tutorial PHP Advanced PHP Resources

The PHP Math decbin() function returns a string which is the binary representation of a decimal number.




number Required. Specify the decimal number to convert.

Return Value

Binary string representation of a decimal number.


In the below example, decbin() function returns the binary string representation of a given decimal number.

$x = 100; 
$y = 500;
$z = 1000;

echo "decbin($x) returns: ".decbin($x)."\n";
echo "decbin($y) returns: ".decbin($y)."\n";
echo "decbin($z) returns: ".decbin($z)."\n";

The output of the above code will be:

decbin(100) returns: 1100100
decbin(500) returns: 111110100
decbin(1000) returns: 1111101000

❮ PHP Math Functions