Skip to content
Related Articles

Related Articles

PHP | decbin( ) Function

Improve Article
Save Article
Like Article
  • Last Updated : 09 Mar, 2018

While working with numbers, many times we need to convert the bases of number and one of the most frequent used conversion is decimal to binary conversion. PHP provides us with a built-in function, decbin() for this purpose.The decbin() function in PHP is used to return a string containing a binary representation of the given decimal number argument.
decbin stands for decimal to binary.


string decbin(value)

Parameters: This function accepts a single parameter value. It is the decimal number which you want to convert in binary representation.

Return Value: It returns a string that represent the binary value of the decimal number passed to the function as argument.


Input : decbin(12)
Output : 1100

Input : decbin(26)
Output : 11010

Input : decbin(2147483647)
Output : 1111111111111111111111111111111 (31 1's)

Below programs illustrate the decbin() function in PHP:

  • Passing 12 as a parameter

    echo decbin(12);


  • Passing 26 as a parameter:

    echo decbin(26);


  • When the largest signed integer is passed as a parameter:

    echo decbin(2147483647);




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!