PHP bindec() Function: Converting Binary Strings to Decimal

This article explains how the PHP bindec() function converts binary strings to their decimal equivalents, describes its parameters and return values, and provides example code with expected output for developers working on backend applications.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
PHP bindec() Function: Converting Binary Strings to Decimal

The PHP bindec() function converts a binary string to its decimal equivalent, returning an integer or float depending on size.

It interprets the binary string as an unsigned integer, treating the most‑significant bit as a magnitude rather than a sign.

Parameter: $binary_string – the binary string to be converted.

Return value: the decimal value of the binary string.

Example:

<?php
echo bindec('110011') . "
";
echo bindec('000110011') . "
";
echo bindec('111') . "
";
?>

Output:

51
51
7
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendPHPTutorialDecimalbinary conversionbindec
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.