PHP decbin() Function
In this chapter you will learn:
- Definition for PHP decbin() Function
- Syntax for PHP decbin() Function
- Parameter for PHP decbin() Function
- Return for PHP decbin() Function
- 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
Parameter | Is Required | Description |
---|---|---|
num | Required. | Decimal value to convert |
Return
Item | Description |
---|---|
Return Value | A 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:
- Definition for PHP dechex() Function
- Syntax for PHP dechex() Function
- Parameter for PHP dechex() Function
- Return for PHP dechex() Function
- Note for PHP dechex() Function
- Example - converts a decimal number into a binary number
Home » PHP Tutorial » PHP Math Functions