奇怪的输出,当数字以 0 开头时 [英] Weird output, when number starts with 0
本文介绍了奇怪的输出,当数字以 0 开头时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
1.脚本:
$num = "00445790";
echo $num;
返回:
00445790
2.脚本
$num = 00445790;
echo $num;
返回:
2351
有人可以解释为什么我在第二个脚本中得到 2351
吗?
Can somebody explain why I get 2351
on the second script?
推荐答案
Integers
以零开头的被认为是八进制.因为八进制整数只使用从 0 到 8 的数字,所以从 9
开始的所有内容都被忽略了.
Integers
that start with zero are consider octal. Because octal integers only use numbers from 0 to 8 everything from the 9
on are ignored.
所以00445790
变成了004457
,也就是十进制的2351
.
So 00445790
becomes 004457
which is 2351
in decimal.
这篇关于奇怪的输出,当数字以 0 开头时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文