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.

Syntax

decbin(number)

Parameters

number Required. Specify the decimal number to convert.

Return Value

Binary string representation of a decimal number.

Example:

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

<?php
$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