decbin

string decbin(int dec) 

Returns the binary representation of the specified decimal integer argument.

Returns:

String binary representation of an integer

Description:

Converts a decimal number into a string containing its binary representation. The largest decimal value that can be converted is 2147483647. If you have to deal with larger numbers, you need to write a custom function to handle the values.

Version:

PHP 3, PHP 4

See also:

base_convert() 
bindec() 
dechex() 
hexdec() 
decoct() 
octdec() 

Example:

Get the binary representation of an integer
$number = 42; 
echo "The binary of $number is ", decbin($number); 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.