📅  最后修改于: 2023-12-03 14:45:14.186000             🧑  作者: Mango
decoct()
函数将一个十进制数转换为八进制数。该函数接收一个十进制数作为参数,并返回相应的八进制数。
decoct(number $decimal_number): string
参数:
$decimal_number
: 必选参数,待转换的十进制数。返回值:
$num1 = 18;
$num2 = 16;
$oct1 = decoct($num1);
$oct2 = decoct($num2);
echo "The octal equivalent of $num1 is $oct1\n";
echo "The octal equivalent of $num2 is $oct2\n";
输出结果:
The octal equivalent of 18 is 22
The octal equivalent of 16 is 20
$decimal_number
参数为无效的十进制数,则返回空字符串 ''
。decoct()
函数只需要一个参数,不支持多个参数同时转换。