php int的前导零是什么? [英] What does a leading zero do for a php int?

查看:68
本文介绍了php int的前导零是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

echo(073032097109032116104101032118101114121032109111100101108032111102032097032109111100101114110032109097106111114032103101110101114097108046);

从本质上讲,非常大.现在,为什么输出241872?我知道PHP具有浮动处理程序.当我删除前导零时,它会按预期运行.前导零表示什么?

Essentially, a very large number. Now, why does it output 241872? I know PHP has float handlers. When I remove the leading zero, it functions as expected. What is that leading zero signifying?

推荐答案

如果使用前导零,则PHP将数字解释为

If you use a leading zero, the number is interpreted by PHP as an octal number. Thus, a 9 is not a valid part of the number and the parser stops there:

  0730320 (base 8)
=  7 * 8^5 + 3 * 8^4 + 3 * 8^2 + 2 * 8^1
=  7 * 32768 + 3 * 4096 + 3 * 64 + 2 * 8 (base 10)
=  241872 (base 10)

这篇关于php int的前导零是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆