PHP bindec() Function

Definition and Usage

The bindec() function returns decinmal equivalent of a binary number represented as a string argument. Binary number inside string is interpreted as unigned integer.

This function returns a decimal integer. However, it may return float for size reasons.

Syntax

bindec ( string $binary_string ) : number

Parameters

Sr.No Parameter & Description
1 binary_string
A string containing binary number representation. Invalid characters (other than 1 and 0) are ignored.

Return Values

PHP bindec() function returns decimal equivalent of given binary number inside string.

PHP Version

This function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.

Example

<?php
   $arg='-1111';
   $val=bindec($arg);
   echo "bindec('" . $arg . "') = " . $val;
?>

Output

This will produce following result −

bindec('-1111') = 15
Updated on: 2026-03-11T23:22:53+05:30

261 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements