PHP Tutorial - PHP decbin() Function






Definition

The decbin() function converts a decimal number into a binary number.

Syntax

PHP decbin() Function has the following format.

string decbin ( int num )

Parameter

ParameterIs Required Description
num Required.Decimal value to convert

Return

Item Description
Return ValueA string that contains the binary number of the decimal value
Return Type String




Example

Converts a decimal number into a binary number


<?PHP
    print decbin(16); // "10000" 
    echo decbin("3") . "\n";
    echo decbin("1") . "\n";
    echo decbin("15") . "\n";
    echo decbin("7");
?>

The code above generates the following result.