PHP decbin() Function

Definition and Usage

The decbin() function converts decimal to binary.

Syntax

decbin(dec_number)
Parameter Description
dec_number Required. Specifies the decimal number to be converted.

Description

Returns a string containing the given dec_number Binary representation of the parameter. The maximum number that can be converted is decimal 4294967295, resulting in a string of 32 ones.

Example

<?php
echo decbin("3");
echo decbin("1");
echo decbin("1587");
echo decbin("7");
?>

Output:

11
1
11000110011
111