PHP 中的点运算符
我以为我已经知道 字符串运算符 。
很好,直到今天我被问到了一个问题。这个问题看起来很简单:
echo 100...100;
乍一看我以为它会出现语法错误。但当我运行代码并看到结果时,我完全困惑了。结果是
1000.1
所以我想知道怎么会发生这种情况?
谢谢。
I thought I've known the String Operator .
well enough until I was asked a question about it today. The question looks quite simple:
echo 100...100;
At the first glance I thought it would make a syntax error. But when I ran the code and saw the result I was totally confused. The result is
1000.1
So I wonder how could this happen?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
像这样阅读:
因此它连接了
100
和0.1
。Read it like this:
Thus it concats
100
and0.1
.假设您的
意思是 PHP 的优点。 :)
该语句被理解为
相当于
<=>
<=>
Assuming you meant
The reason for this is the beauty of PHP. :)
This statement is understood as
which is equivalent to
<=>
<=>
您可以将其读作
echo 100 。 0.1 。
You can read it as
echo 100 . 0.1
.实际上,只有在没有引号的情况下才有效:
Actually, that only works without the quotes: