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//from  ww  w  .  j a v a2  s  .c  om
    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.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions