The bindec() function converts a binary number into a decimal number.
PHP bindec() Function has the following format.
number bindec ( string binary_num )
Parameter | Is Required | Description |
---|---|---|
binary_num | Required. | binary string to convert. |
Return | Description |
---|---|
Return Value | The decimal value of binary_string |
Return Type | Float / Integer |
Convert binary to decimal:
<?php
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.