当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


PHP decbin()用法及代码示例


PHP decbin() 函数是数学函数,用于将十进制数转换为二进制数。它返回二进制数。

用法:

string decbin ( int $number );
参数 描述 必需/可选
number 指定要转换的十进制值 Required

例子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






相关用法


注:本文由纯净天空筛选整理自 PHP decbin() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。