位置:首页  >   程序积累  > php安装vld扩展查看编译opcode

php安装vld扩展查看编译opcode


php安装vld扩展查看编译opcode

wget http://pecl.php.net/get/vld-0.14.0.tgz

tar -zxvf vld-0.14.0.tgz 

/usr/local/php/bin/phpize 

./configure --with-php-config=/usr/local/php/bin/php-config --enable-vld

make && make install 

vim /usr/local/php/etc/php.ini ,在文件最后面加入 extension=vld.so

service php-fpm restart //重启php-fpm


例子 

vim array.php
<?php
        $tmp = array('a'=>'a','b'=>'b','c'=>'c');
        $a = $tmp['a'];
        $b = $tmp[b];
        $c = $tmp["c"];


然后执行 
php -dvld.active=1 ./array.php    //如果加入 -dvld.execute=0(默认是1),则文件只输出opcode而不执行

返回结果如下
Finding entry points
Branch analysis from position: 0
Jump found. (Code = 62) Position 1 = -2
filename:       /data/www/study/array.php
function name:  (null)
number of ops:  9
compiled vars:  !0 = $tmp, !1 = $a, !2 = $b, !3 = $c
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   ASSIGN                                                   !0, <array>
   3     1        FETCH_DIM_R                                      $5      !0, 'a'
         2        ASSIGN                                                   !1, $5
   4     3        FETCH_CONSTANT                                   ~7      'b'
         4        FETCH_DIM_R                                      $8      !0, ~7
         5        ASSIGN                                                   !2, $8
   5     6        FETCH_DIM_R                                      $10     !0, 'c'
         7        ASSIGN                                                   !3, $10
   6     8      > RETURN                                                   1

branch: #  0; line:     2-    6; sop:     0; eop:     8; out1:  -2
path #1: 0, 
PHP Notice:  Use of undefined constant b - assumed 'b' in /data/www/study/array.php on line 4	

可以看到$tmp[b] 在编译成opcode的时候就比其他两个多一步



文章属性
精彩评论