PHP bindec() Function
In this chapter you will learn:
- Definition for PHP bindec() Function
- Syntax for PHP bindec() Function
- Parameter for PHP bindec() Function
- Return for PHP bindec() Function
- Example - Convert binary to decimal
Definition
The bindec() function converts a binary number into a decimal number.
Syntax
PHP bindec() Function has the following format.
number bindec ( string binary_num )
Parameter
Parameter | Is Required | Description |
---|---|---|
binary_num | Required. | binary string to convert. |
Return
Return | Description |
---|---|
Return Value | The decimal value of binary_string |
Return Type | Float / Integer |
Example
Convert binary to decimal:
<?php//from j av a 2 s .c om
print decbin("10000"); // 16
echo "\n";
echo bindec("0011") . "\n";
echo bindec("01") . "\n";
echo bindec("11000110011") . "\n";
echo bindec("111");
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP ceil() Function
- Syntax for PHP ceil() Function
- Parameter for PHP ceil() Function
- Return for PHP ceil() Function
- Note for PHP ceil() Function
- Example - Round numbers up to the nearest integer
Home » PHP Tutorial » PHP Math Functions