PHP用VLD查看php的Opcode级执行-创新互联

VLD是php的一个扩展,用于查看php的Opcode级的操作。

VLD包的下载网址:http://pecl.php.net/package/vld

用php的pecl安装方法:pecl install channel://pecl.php.net/vld-0.10.1

使用方法如
1、用于测试的文件为testvld.php,内容如下
function _count($num){
  if($num==0){
       return 0;
  }else{
       return $num + _count($num-1);
  }
}
echo _count(10);
?>

创新互联自2013年创立以来,是专业互联网技术服务公司,拥有项目成都网站设计、成都做网站网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元焉耆做网站,已为上家服务,为焉耆各地企业和个人服务,联系电话:18982081108

2、根据各自的环境来用php命令加-dvld.active=1来执行文件,如本人环境中执行命令:/usr/local/php-5.6.4/bin/php -c /usr/local/php-5.6.4/php.ini -dvld.active=1 testvld.php

3、通过vld对testvld.php执行结果如下:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:      /home/file/testvld.php
function name: (null)
number of ops: 5
compiled vars: none
line    #* E I O op                          fetch         ext return operands
-------------------------------------------------------------------------------------
  2    0 E >  NOP
  9    1       SEND_VAL                                                10
        2       DO_FCALL                                     1 $0     '_count'
        3       ECHO                                                    $0
 11    4     > RETURN                                                  1

branch: # 0; line:    2-  11; sop:    0; eop:    4; out1: -2
path #1: 0,
Function _count:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
Jump found. Position 1 = -2
Branch analysis from position: 5
Jump found. Position 1 = -2
filename:      /home/file/testvld.php
function name: _count
number of ops: 12
compiled vars: !0 = $num
line    #* E I O op                          fetch         ext return operands
-------------------------------------------------------------------------------------
  2    0 E >  RECV                                            !0
  3    1       IS_EQUAL                                        ~0     !0, 0
        2     > JMPZ                                                    ~0, ->5
  4    3   > > RETURN                                                  0
  5    4*      JMP                                                     ->11
  6    5   >  INIT_FCALL_BY_NAME                                      '_count'
        6       SUB                                             ~1     !0, 1
        7       SEND_VAL                                                ~1
        8       DO_FCALL_BY_NAME                             1 $2
        9       ADD                                             ~3     !0, $2
       10     > RETURN                                                  ~3
  8   11*    > RETURN                                                  null

branch: # 0; line:    2-   3; sop:    0; eop:    2; out1:  3; out2:  5
branch: # 3; line:    4-   4; sop:    3; eop:    3; out1: -2
branch: # 5; line:    6-   8; sop:    5; eop:   11
path #1: 0, 3,
path #2: 0, 5,
End of function _count

重点分析:
number of ops: Opcode级的操作总个数
列表中的op:具体的操作名

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


新闻名称:PHP用VLD查看php的Opcode级执行-创新互联
转载来源:http://myzitong.com/article/cddjhh.html