PHP decbin() Function

In this chapter you will learn:

  1. Definition for PHP decbin() Function
  2. Syntax for PHP decbin() Function
  3. Parameter for PHP decbin() Function
  4. Return for PHP decbin() Function
  5. Example - converts a decimal number into a binary number

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   jav  a 2  s  . c  o m*/
    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.

Next chapter...

What you will learn in the next chapter:

  1. Definition for PHP dechex() Function
  2. Syntax for PHP dechex() Function
  3. Parameter for PHP dechex() Function
  4. Return for PHP dechex() Function
  5. Note for PHP dechex() Function
  6. Example - converts a decimal number into a binary number