Facebook Page Twitter Page LinkedIn Page
× PHP Tutorial PHP Advanced PHP Resources


The PHP bindec() function is used to return the decimal number equivalent to the binary number represented by the binary string argument.

Syntax

bindec(bin_string)

Parameters

bin_string Required. Specify the binary number to convert.

Return Value

The decimal representation of a binary string argument.

Example:

In the below example, bindec() function is used to return the decimal representation of a binary string argument.

<?php
  $x = '101010'; 
  $y = 111000;
  $z = 100000;

  echo "bindec($x) returns: ".bindec($x)."\n";
  echo "bindec($y) returns: ".bindec($y)."\n";
  echo "bindec($z) returns: ".bindec($z)."\n";
?>

The output of the above code will be:

bindec(101010) returns: 42
bindec(111000) returns: 56
bindec(100000) returns: 32

❮ PHP Math Functions