PHP bindec() Function
Definition and Usage
The bindec() function converts binary to decimal.
Syntax
bindec(binary_string)
Parameter | Description |
---|---|
binary_string | Required. Specifies the binary number to be converted. |
Description
Returns binary_string The decimal equivalent of the binary number represented by the parameter.
The bindec() function converts a binary number to an integer. The largest number that can be converted is 31 ones or decimal 2147483647. Starting from PHP 4.1.0, this function can handle large numbers, in which case it will return a float type.
Example
<?php echo bindec("0011"); echo bindec("01"); echo bindec("11000110011"); echo bindec("111"); ?>
Output:
3 1 1587 7