PHP decbin() 函数
PHP decbin() 函数是用于将十进制数转换为二进制数的数学函数。它返回二进制数。
语法
string decbin ( int $number );
参数 | 描述 | 必需/可选 |
---|---|---|
number(数字) | 指定要转换的十进制值 | 必需 |
示例1
<?php
decimal='14';
echo "Your Decimal number is : ".decimal."<br>";
echo "By using 'decbin()'function your Binary number is :".decbin($decimal);
?>
输出:
Your Decimal number is : 14
By using 'decbin()'function your Binary number is :1110
示例2
<?php
decimal=3;
echo "Your Decimal number is : ".decimal."<br>";
echo "By using 'decbin()'function your Binary number is :".decbin($decimal);
?>
输出:
Your Decimal number is : 3
By using 'decbin()'function your Binary number is :11
示例3
<?php
decimal=1;
echo "Your Decimal number is : ".decimal."<br>";
echo "By using 'decbin()'function your Binary number is :".decbin($decimal);
?>
输出:
Your Decimal number is : 1
By using 'decbin()'function your Binary number is :1
示例4
<?php
decimal=1569;
echo "Your Decimal number is : ".decimal."<br>";
echo "By using 'decbin()'function your Binary number is :".decbin($decimal);
?>
输出:
Your Decimal number is : 1569
By using 'decbin()'function your Binary number is :11000100001
示例5
<?php
decimal=7;
echo "Your Decimal number is : ".decimal."<br>";
echo "By using 'decbin()'function your Binary number is :".decbin($decimal);
?>
输出:
Your Decimal number is : 7
By using 'decbin()'function your Binary number is :111