首页 > Web开发 > 详细

PHP一些优先级的问题

时间:2015-07-29 00:33:29      阅读:249      评论:0      收藏:0      [点我收藏+]

直接看代码

<?php
echo ‘1‘.print(2)+3,"\n";

 不错,就是这么简单,但是很少有人能正确回答

我们执行一下

[root@localhost test]# php -dvld.active=1  test7.php    
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /data/www/test/test7.php
function name:  (null)
number of ops:  6
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   ADD                                              ~0      2, 3
         1        PRINT                                            ~1      ~0
         2        CONCAT                                           ~2      ‘1‘, ~1
         3        ECHO                                                     ~2
         4        ECHO                                                     ‘%0A‘
   3     5      > RETURN                                                   1

branch: #  0; line:     2-    3; sop:     0; eop:     5; out1:  -2
path #1: 0, 
511

 让人很诧异吧

换一种写法

<?php
echo ‘1‘,print(2)+3,"\n";

 执行结果

[root@localhost test]# php -dvld.active=1  test7.php 
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /data/www/test/test7.php
function name:  (null)
number of ops:  6
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   ECHO                                                     ‘1‘
         1        ADD                                              ~0      2, 3
         2        PRINT                                            ~1      ~0
         3        ECHO                                                     ~1
         4        ECHO                                                     ‘%0A‘
   3     5      > RETURN                                                   1

branch: #  0; line:     2-    3; sop:     0; eop:     5; out1:  -2
path #1: 0, 
151

 再换一种

<?php
echo print(2)+3,"\n";

 执行结果

[root@localhost test]# php -dvld.active=1  test7.php 
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /data/www/test/test7.php
function name:  (null)
number of ops:  5
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   ADD                                              ~0      2, 3
         1        PRINT                                            ~1      ~0
         2        ECHO                                                     ~1
         3        ECHO                                                     ‘%0A‘
   3     4      > RETURN                                                   1

branch: #  0; line:     2-    3; sop:     0; eop:     4; out1:  -2
path #1: 0, 
51

 未完待续……

PHP一些优先级的问题

原文:http://www.cnblogs.com/chenpingzhao/p/4684694.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!