當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。