PHP bindec()Function

PHP Math 参考手册PHP Math Reference Manual

Example

Convert binary to decimal:

<?php
echo bindec("0011") . "<br>";
echo bindec("01") . "<br>";
echo bindec("11000110011") . "<br>";
echo bindec("111");
?>

Run example »

Definition and Usage

The bindec() function converts a binary number to a decimal number.

Tip:To convert decimal to binary, seedecbin()function.


Syntax

bindec(binary_string);

Parameters Description
binary_string Required. Specifies the binary string to convert.
Note:
The parameter value must be a string!

Technical Details

Return value: binary_stringThe decimal value of.
Return type: Float / Integer
PHP Version: 4+


PHP Math 参考手册PHP Math Reference Manual Other Extensions