Home > Article > Backend Development > How to convert decimal to binary in php
In PHP, you can use the decbin() function to convert a decimal number into a binary number. The return result of this function is a binary number containing a decimal value. The syntax is "decbin(number);".
The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.
The decbin() function converts decimal numbers into binary numbers.
To convert binary to decimal, please see bindec() function
Syntax
decbin(number);
Parameter Description
number Required. Specifies the decimal value to be converted.
Return value: A string containing a binary number with a decimal value.
Examples are as follows:
<?php echo decbin("3") . "<br>"; echo decbin("1") . "<br>"; echo decbin("1587") . "<br>"; echo decbin("7"); ?>
Output results:
PHP Video Tutorial 》
The above is the detailed content of How to convert decimal to binary in php. For more information, please follow other related articles on the PHP Chinese website!