1
heimonsy 2014 年 12 月 5 日
会解析成
echo '1' . print 3 + 2 参考php手册: http://php.net/manual/zh/function.print.php print 实际上不是一个函数(它是一个语言结构),因此你可以不必使用圆括号来括起它的参数列表 |
2
Paranoid 2014 年 12 月 5 日
这种就是抖机灵
会用在工程中么? |
3
leiliang 2014 年 12 月 5 日
要看php引擎是怎么编译的以及对数据类型怎么转换的,这种东西,不深入到底层还真是说不清楚
|
4
vibbow 2014 年 12 月 6 日
运行结果居然是511?!
|
5
gDD 2014 年 12 月 6 日 参考 @heimonsy 的链接,里面有这个一句:But since the parenthesis around the argument are not required, they are interpretet as part of the argument.
也就是说,在这里[echo '1'.print(3)+2],print 后面的都被作为了 print 的参数,所以会被解析成 echo '1' . (print 3 + 2) 首先 print 部分被执行了,输出5 由于print永远会返回1,这个1与字符串‘1’相加(.),成为了字符串‘11’ 这个字符串‘11‘被echo出来 就是 @vibbow 的结果,显示为’511‘。 |
6
yinxingren 2014 年 12 月 6 日 via Android
|