PHP bindec() Function

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 RequiredDescription
binary_numRequired. binary string to convert.

Return

Return Description
Return ValueThe decimal value of binary_string
Return Type Float / Integer

Example

Convert binary to decimal:


<?php/*  ww  w . ja v  a 2  s.c  o  m*/
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.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions