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


PHP decoct()用法及代碼示例


Php decoct() 是重要的預定義數學函數。它用於將十進製數轉換為八進製數。

用法:

string decoct ( int $number );
參數 描述 必需/可選
number 指定十進製值 Required

例子1

<?php
$decimal=15;
echo "Your Decimal number is:".$decimal."<br>";	
echo "By using 'decoct()'function, your Octal number is:".decoct($decimal);
?>

輸出:

Your Decimal number is:15
By using 'decoct()'function, your Octal number is:17

例子2

<?php
$decimal=264;
echo "Your Decimal number is:".$decimal."<br>";	
echo "By using 'decoct()'function, your Octal number is:".decoct($decimal);
?>

輸出:

Your Decimal number is:264
By using 'decoct()'function, your Octal number is:410

例子3

<?php
$decimal=30;
echo "Your Decimal number is:".$decimal."<br>";	
echo "By using 'decoct()'function, your Octal number is:".decoct($decimal);
?>

輸出:

Your Decimal number is:30
By using 'decoct()'function, your Octal number is:36

示例 4

<?php
$decimal=70;
echo "Your Decimal number is:".$decimal."<br>";	
echo "By using 'decoct()'function, your Octal number is:".decoct($decimal);
?>

輸出:

Your Decimal number is:70
By using 'decoct()'function, your Octal number is:106

例 5

<?php
$decimal=9999;
echo "Your Decimal number is:".$decimal."<br>";	
echo "By using 'decoct()'function, your Octal number is:".decoct($decimal);
?>

輸出:

Your Decimal number is:9999
By using 'decoct()'function, your Octal number is:23417






相關用法


注:本文由純淨天空篩選整理自 PHP decoct() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。