假设有以下代码:
<?php
echo 'hello' . print 123;
被执行。
我期望的是hello123
,但实际输出是123hello1
.
为什么123排在第一位?为什么输出包含1
在最后?
(我还尝试在两边加上一对括号hello
,但结果仍然相同。)
echo 'hello' . print 123;
这连接'hello'
与返回值 of print 123
。前print
returns价值1
, it outputs 123
。串联的hello1
is output之后由echo
。所以评价是:
- output
123
- return
1
- 连接
'hello'
and 1
- output
hello1
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)