PHP decbin( ) Function
Last Updated :
22 Jun, 2023
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.
Syntax:
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.
Examples:
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:
Reference:
http://php.net/manual/en/function.decbin.php
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...