Backend Development 1 min read

Converting Decimal Numbers to Binary in PHP with decbin()

This article explains how to use PHP's built‑in decbin() function to convert decimal integers into their binary string representation, covering the function syntax, parameter details, return limits, and providing a clear code example with expected output.

php中文网 Courses
php中文网 Courses
php中文网 Courses
Converting Decimal Numbers to Binary in PHP with decbin()

In everyday use we work with decimal numbers, while computers operate in binary; this article explains how to convert decimal to binary in PHP.

The built‑in decbin() function takes an integer $number and returns a string containing its binary representation, supporting values up to 4294967295 (32 bits).

Example usage:

<?php
echo decbin(6) . "<br>";
echo decbin(4294967295) . "<br>";
?>

The output will be:

110
11111111111111111111111111111111
Decimalconversionbinarydecbin
php中文网 Courses
Written by

php中文网 Courses

php中文网's platform for the latest courses and technical articles, helping PHP learners advance quickly.

0 followers
Reader feedback

How this landed with the community

login 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.