PHP | decbin( ) Function
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:
- Passing 12 as a parameter
<?phpecho decbin(12);?>chevron_rightfilter_noneOutput:
1100
- Passing 26 as a parameter:
<?phpecho decbin(26);?>chevron_rightfilter_noneOutput:
11010
- When the largest signed integer is passed as a parameter:
<?phpecho decbin(2147483647);?>chevron_rightfilter_noneOutput:
1111111111111111111111111111111
Reference:
http://php.net/manual/en/function.decbin.php
Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- How to get the function name inside a function in PHP ?
- D3.js | d3.map.set() Function
- p5.js | box() Function
- PHP | max( ) Function
- CSS | rgb() Function
- PHP | min( ) Function
- PHP | Ds\Map get() Function
- p5.js | str() function
- p5.js | int() function
- PHP | dir() Function
- D3.js | d3.hcl() Function
- D3.js | d3.lab() Function
- p5.js | value() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



