PHP bindec() functiun

Definition and Usage

The bindec() functiun converts binary to decimal.

Syntax

bindec(binary_string)
Parameter Description
binary_string Required. Specifies the binary number to be converted.

Description

Return binary_string Decimal equivalent of the binary number represented by the parameter.

The bindec() functiun converts a binary number to an integer. The largest number that can be converted is 31 ones or 2147483647 in decimal. Starting from PHP 4.1.0, this functiun can handle large numbers, and in this 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