PHP安装parsekit扩展查看opcode

本文介绍如何使用Parsekit扩展来查看PHP代码的opcode,包括单句PHP代码、文件和函数的opcode查看方法,并提供了详细的步骤和示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文地址:PHP安装parsekit扩展查看opcode


也可以通过VLD查看,具体请看本人写的http://blog.youkuaiyun.com/21aspnet/article/details/7002644

 

安装parsekit扩展

http://pecl.php.net/package/parsekit

下载最新的

#wget http://pecl.php.net/get/parsekit-1.3.0.tgz

安装过程省略

可以参考  本人写的http://blog.youkuaiyun.com/21aspnet/article/details/7035392  安装apc扩展是一样的原理

还是自动安装很方便

安装:

# /usr/local/PHP/bin/pecl install parsekit     

配置:

php.ini加extension=parsekit.so    

重启:

# /usr/local/apache2/bin/apachectl restart  

测试:

# /usr/local/php/bin/php -r "var_dump(parsekit_compile_string('print 1+1;'));"

输出:

[html]  view plain  copy
  1. array(19) {  
  2.   ["type"]=>  
  3.   int(4)  
  4.   ["type_name"]=>  
  5.   string(14) "ZEND_EVAL_CODE"  
  6.   ["fn_flags"]=>  
  7.   int(0)  
  8.   ["num_args"]=>  
  9.   int(0)  
  10.   ["required_num_args"]=>  
  11.   int(0)  
  12.   ["pass_rest_by_reference"]=>  
  13.   bool(false)  
  14.   ["line_start"]=>  
  15.   int(0)  
  16.   ["line_end"]=>  
  17.   int(0)  
  18.   ["return_reference"]=>  
  19.   bool(false)  
  20.   ["refcount"]=>  
  21.   int(1)  
  22.   ["last"]=>  
  23.   int(4)  
  24.   ["size"]=>  
  25.   int(4)  
  26.   ["T"]=>  
  27.   int(2)  
  28.   ["last_brk_cont"]=>  
  29.   int(0)  
  30.   ["current_brk_cont"]=>  
  31.   int(-1)  
  32.   ["backpatch_count"]=>  
  33.   int(0)  
  34.   ["done_pass_two"]=>  
  35.   bool(true)  
  36.   ["filename"]=>  
  37.   string(17) "Parsekit Compiler"  
  38.   ["opcodes"]=>  
  39.   array(4) {  
  40.     [0]=>  
  41.     array(8) {  
  42.       ["address"]=>  
  43.       int(457076436)  
  44.       ["opcode"]=>  
  45.       int(1)  
  46.       ["opcode_name"]=>  
  47.       string(8) "ZEND_ADD"  
  48.       ["flags"]=>  
  49.       int(197378)  
  50.       ["result"]=>  
  51.       array(3) {  
  52.         ["type"]=>  
  53.         int(2)  
  54.         ["type_name"]=>  
  55.         string(10) "IS_TMP_VAR"  
  56.         ["var"]=>  
  57.         int(0)  
  58.       }  
  59.       ["op1"]=>  
  60.       array(3) {  
  61.         ["type"]=>  
  62.         int(1)  
  63.         ["type_name"]=>  
  64.         string(8) "IS_CONST"  
  65.         ["constant"]=>  
  66.         &int(1)  
  67.       }  
  68.       ["op2"]=>  
  69.       array(3) {  
  70.         ["type"]=>  
  71.         int(1)  
  72.         ["type_name"]=>  
  73.         string(8) "IS_CONST"  
  74.         ["constant"]=>  
  75.         &int(1)  
  76.       }  
  77.       ["lineno"]=>  
  78.       int(1)  
  79.     }  
  80.     [1]=>  
  81.     array(7) {  
  82.       ["address"]=>  
  83.       int(457076556)  
  84.       ["opcode"]=>  
  85.       int(41)  
  86.       ["opcode_name"]=>  
  87.       string(10) "ZEND_PRINT"  
  88.       ["flags"]=>  
  89.       int(770)  
  90.       ["result"]=>  
  91.       array(3) {  
  92.         ["type"]=>  
  93.         int(2)  
  94.         ["type_name"]=>  
  95.         string(10) "IS_TMP_VAR"  
  96.         ["var"]=>  
  97.         int(1)  
  98.       }  
  99.       ["op1"]=>  
  100.       array(3) {  
  101.         ["type"]=>  
  102.         int(2)  
  103.         ["type_name"]=>  
  104.         string(10) "IS_TMP_VAR"  
  105.         ["var"]=>  
  106.         int(0)  
  107.       }  
  108.       ["lineno"]=>  
  109.       int(1)  
  110.     }  
  111.     [2]=>  
  112.     array(7) {  
  113.       ["address"]=>  
  114.       int(457076676)  
  115.       ["opcode"]=>  
  116.       int(70)  
  117.       ["opcode_name"]=>  
  118.       string(9) "ZEND_FREE"  
  119.       ["flags"]=>  
  120.       int(271104)  
  121.       ["op1"]=>  
  122.       array(4) {  
  123.         ["type"]=>  
  124.         int(2)  
  125.         ["type_name"]=>  
  126.         string(10) "IS_TMP_VAR"  
  127.         ["var"]=>  
  128.         int(1)  
  129.         ["EA.type"]=>  
  130.         int(0)  
  131.       }  
  132.       ["op2"]=>  
  133.       array(3) {  
  134.         ["type"]=>  
  135.         int(8)  
  136.         ["type_name"]=>  
  137.         string(9) "IS_UNUSED"  
  138.         ["opline_num"]=>  
  139.         string(1) "0"  
  140.       }  
  141.       ["lineno"]=>  
  142.       int(1)  
  143.     }  
  144.     [3]=>  
  145.     array(7) {  
  146.       ["address"]=>  
  147.       int(457076796)  
  148.       ["opcode"]=>  
  149.       int(62)  
  150.       ["opcode_name"]=>  
  151.       string(11) "ZEND_RETURN"  
  152.       ["flags"]=>  
  153.       int(16777984)  
  154.       ["op1"]=>  
  155.       array(3) {  
  156.         ["type"]=>  
  157.         int(1)  
  158.         ["type_name"]=>  
  159.         string(8) "IS_CONST"  
  160.         ["constant"]=>  
  161.         &NULL  
  162.       }  
  163.       ["extended_value"]=>  
  164.       int(0)  
  165.       ["lineno"]=>  
  166.       int(1)  
  167.     }  
  168.   }  
  169. }  


 

 再看输出hello word

# /usr/local/php/bin/php -r "var_dump(parsekit_compile_string('print \"hello word\";'));"

输出:

 

[html]  view plain  copy
  1. array(19) {  
  2.   ["type"]=>  
  3.   int(4)  
  4.   ["type_name"]=>  
  5.   string(14) "ZEND_EVAL_CODE"  
  6.   ["fn_flags"]=>  
  7.   int(0)  
  8.   ["num_args"]=>  
  9.   int(0)  
  10.   ["required_num_args"]=>  
  11.   int(0)  
  12.   ["pass_rest_by_reference"]=>  
  13.   bool(false)  
  14.   ["line_start"]=>  
  15.   int(0)  
  16.   ["line_end"]=>  
  17.   int(0)  
  18.   ["return_reference"]=>  
  19.   bool(false)  
  20.   ["refcount"]=>  
  21.   int(1)  
  22.   ["last"]=>  
  23.   int(3)  
  24.   ["size"]=>  
  25.   int(3)  
  26.   ["T"]=>  
  27.   int(1)  
  28.   ["last_brk_cont"]=>  
  29.   int(0)  
  30.   ["current_brk_cont"]=>  
  31.   int(-1)  
  32.   ["backpatch_count"]=>  
  33.   int(0)  
  34.   ["done_pass_two"]=>  
  35.   bool(true)  
  36.   ["filename"]=>  
  37.   string(17) "Parsekit Compiler"  
  38.   ["opcodes"]=>  
  39.   array(3) {  
  40.     [0]=>  
  41.     array(7) {  
  42.       ["address"]=>  
  43.       int(536780564)  
  44.       ["opcode"]=>  
  45.       int(41)  
  46.       ["opcode_name"]=>  
  47.       string(10) "ZEND_PRINT"  
  48.       ["flags"]=>  
  49.       int(770)  
  50.       ["result"]=>  
  51.       array(3) {  
  52.         ["type"]=>  
  53.         int(2)  
  54.         ["type_name"]=>  
  55.         string(10) "IS_TMP_VAR"  
  56.         ["var"]=>  
  57.         int(0)  
  58.       }  
  59.       ["op1"]=>  
  60.       array(3) {  
  61.         ["type"]=>  
  62.         int(1)  
  63.         ["type_name"]=>  
  64.         string(8) "IS_CONST"  
  65.         ["constant"]=>  
  66.         &string(10) "hello word"  
  67.       }  
  68.       ["lineno"]=>  
  69.       int(1)  
  70.     }  
  71.     [1]=>  
  72.     array(7) {  
  73.       ["address"]=>  
  74.       int(536780684)  
  75.       ["opcode"]=>  
  76.       int(70)  
  77.       ["opcode_name"]=>  
  78.       string(9) "ZEND_FREE"  
  79.       ["flags"]=>  
  80.       int(271104)  
  81.       ["op1"]=>  
  82.       array(4) {  
  83.         ["type"]=>  
  84.         int(2)  
  85.         ["type_name"]=>  
  86.         string(10) "IS_TMP_VAR"  
  87.         ["var"]=>  
  88.         int(0)  
  89.         ["EA.type"]=>  
  90.         int(0)  
  91.       }  
  92.       ["op2"]=>  
  93.       array(3) {  
  94.         ["type"]=>  
  95.         int(8)  
  96.         ["type_name"]=>  
  97.         string(9) "IS_UNUSED"  
  98.         ["opline_num"]=>  
  99.         string(1) "0"  
  100.       }  
  101.       ["lineno"]=>  
  102.       int(1)  
  103.     }  
  104.     [2]=>  
  105.     array(7) {  
  106.       ["address"]=>  
  107.       int(536780804)  
  108.       ["opcode"]=>  
  109.       int(62)  
  110.       ["opcode_name"]=>  
  111.       string(11) "ZEND_RETURN"  
  112.       ["flags"]=>  
  113.       int(16777984)  
  114.       ["op1"]=>  
  115.       array(3) {  
  116.         ["type"]=>  
  117.         int(1)  
  118.         ["type_name"]=>  
  119.         string(8) "IS_CONST"  
  120.         ["constant"]=>  
  121.         &NULL  
  122.       }  
  123.       ["extended_value"]=>  
  124.       int(0)  
  125.       ["lineno"]=>  
  126.       int(1)  
  127.     }  
  128.   }  
  129. }  
总结: 两种方法 1.如果要查看单句php的opcode

# /usr/local/php/bin/php -r "var_dump(parsekit_compile_string('print 1+1;'));"

参考 http://www.php.net/manual/zh/function.parsekit-compile-string.php


2.如果要查看网站下某个php文件的opcode

参考  http://www.php.net/manual/zh/function.parsekit-compile-file.php

# /usr/local/php/bin/php -r "var_dump(parsekit_compile_file('/var/www/tb.php'));"

 

3.如果要查看某个函数的opcode

参考 http://www.php.net/manual/zh/function.parsekit-func-arginfo.php

<?php
function foo($barstdClass $baz, &$bomb$bling false) {
}

var_dump(parsekit_func_arginfo('foo'));
?>


也可以通过VLD查看,具体请看本人写的http://blog.youkuaiyun.com/21aspnet/article/details/7002644

 

安装parsekit扩展

http://pecl.php.net/package/parsekit

下载最新的

#wget http://pecl.php.net/get/parsekit-1.3.0.tgz

安装过程省略

可以参考  本人写的http://blog.youkuaiyun.com/21aspnet/article/details/7035392  安装apc扩展是一样的原理

还是自动安装很方便

安装:

# /usr/local/PHP/bin/pecl install parsekit     

配置:

php.ini加extension=parsekit.so    

重启:

# /usr/local/apache2/bin/apachectl restart  

测试:

# /usr/local/php/bin/php -r "var_dump(parsekit_compile_string('print 1+1;'));"

输出:

[html]  view plain  copy
  1. array(19) {  
  2.   ["type"]=>  
  3.   int(4)  
  4.   ["type_name"]=>  
  5.   string(14) "ZEND_EVAL_CODE"  
  6.   ["fn_flags"]=>  
  7.   int(0)  
  8.   ["num_args"]=>  
  9.   int(0)  
  10.   ["required_num_args"]=>  
  11.   int(0)  
  12.   ["pass_rest_by_reference"]=>  
  13.   bool(false)  
  14.   ["line_start"]=>  
  15.   int(0)  
  16.   ["line_end"]=>  
  17.   int(0)  
  18.   ["return_reference"]=>  
  19.   bool(false)  
  20.   ["refcount"]=>  
  21.   int(1)  
  22.   ["last"]=>  
  23.   int(4)  
  24.   ["size"]=>  
  25.   int(4)  
  26.   ["T"]=>  
  27.   int(2)  
  28.   ["last_brk_cont"]=>  
  29.   int(0)  
  30.   ["current_brk_cont"]=>  
  31.   int(-1)  
  32.   ["backpatch_count"]=>  
  33.   int(0)  
  34.   ["done_pass_two"]=>  
  35.   bool(true)  
  36.   ["filename"]=>  
  37.   string(17) "Parsekit Compiler"  
  38.   ["opcodes"]=>  
  39.   array(4) {  
  40.     [0]=>  
  41.     array(8) {  
  42.       ["address"]=>  
  43.       int(457076436)  
  44.       ["opcode"]=>  
  45.       int(1)  
  46.       ["opcode_name"]=>  
  47.       string(8) "ZEND_ADD"  
  48.       ["flags"]=>  
  49.       int(197378)  
  50.       ["result"]=>  
  51.       array(3) {  
  52.         ["type"]=>  
  53.         int(2)  
  54.         ["type_name"]=>  
  55.         string(10) "IS_TMP_VAR"  
  56.         ["var"]=>  
  57.         int(0)  
  58.       }  
  59.       ["op1"]=>  
  60.       array(3) {  
  61.         ["type"]=>  
  62.         int(1)  
  63.         ["type_name"]=>  
  64.         string(8) "IS_CONST"  
  65.         ["constant"]=>  
  66.         &int(1)  
  67.       }  
  68.       ["op2"]=>  
  69.       array(3) {  
  70.         ["type"]=>  
  71.         int(1)  
  72.         ["type_name"]=>  
  73.         string(8) "IS_CONST"  
  74.         ["constant"]=>  
  75.         &int(1)  
  76.       }  
  77.       ["lineno"]=>  
  78.       int(1)  
  79.     }  
  80.     [1]=>  
  81.     array(7) {  
  82.       ["address"]=>  
  83.       int(457076556)  
  84.       ["opcode"]=>  
  85.       int(41)  
  86.       ["opcode_name"]=>  
  87.       string(10) "ZEND_PRINT"  
  88.       ["flags"]=>  
  89.       int(770)  
  90.       ["result"]=>  
  91.       array(3) {  
  92.         ["type"]=>  
  93.         int(2)  
  94.         ["type_name"]=>  
  95.         string(10) "IS_TMP_VAR"  
  96.         ["var"]=>  
  97.         int(1)  
  98.       }  
  99.       ["op1"]=>  
  100.       array(3) {  
  101.         ["type"]=>  
  102.         int(2)  
  103.         ["type_name"]=>  
  104.         string(10) "IS_TMP_VAR"  
  105.         ["var"]=>  
  106.         int(0)  
  107.       }  
  108.       ["lineno"]=>  
  109.       int(1)  
  110.     }  
  111.     [2]=>  
  112.     array(7) {  
  113.       ["address"]=>  
  114.       int(457076676)  
  115.       ["opcode"]=>  
  116.       int(70)  
  117.       ["opcode_name"]=>  
  118.       string(9) "ZEND_FREE"  
  119.       ["flags"]=>  
  120.       int(271104)  
  121.       ["op1"]=>  
  122.       array(4) {  
  123.         ["type"]=>  
  124.         int(2)  
  125.         ["type_name"]=>  
  126.         string(10) "IS_TMP_VAR"  
  127.         ["var"]=>  
  128.         int(1)  
  129.         ["EA.type"]=>  
  130.         int(0)  
  131.       }  
  132.       ["op2"]=>  
  133.       array(3) {  
  134.         ["type"]=>  
  135.         int(8)  
  136.         ["type_name"]=>  
  137.         string(9) "IS_UNUSED"  
  138.         ["opline_num"]=>  
  139.         string(1) "0"  
  140.       }  
  141.       ["lineno"]=>  
  142.       int(1)  
  143.     }  
  144.     [3]=>  
  145.     array(7) {  
  146.       ["address"]=>  
  147.       int(457076796)  
  148.       ["opcode"]=>  
  149.       int(62)  
  150.       ["opcode_name"]=>  
  151.       string(11) "ZEND_RETURN"  
  152.       ["flags"]=>  
  153.       int(16777984)  
  154.       ["op1"]=>  
  155.       array(3) {  
  156.         ["type"]=>  
  157.         int(1)  
  158.         ["type_name"]=>  
  159.         string(8) "IS_CONST"  
  160.         ["constant"]=>  
  161.         &NULL  
  162.       }  
  163.       ["extended_value"]=>  
  164.       int(0)  
  165.       ["lineno"]=>  
  166.       int(1)  
  167.     }  
  168.   }  
  169. }  


 

 再看输出hello word

# /usr/local/php/bin/php -r "var_dump(parsekit_compile_string('print \"hello word\";'));"

输出:

 

[html]  view plain  copy
  1. array(19) {  
  2.   ["type"]=>  
  3.   int(4)  
  4.   ["type_name"]=>  
  5.   string(14) "ZEND_EVAL_CODE"  
  6.   ["fn_flags"]=>  
  7.   int(0)  
  8.   ["num_args"]=>  
  9.   int(0)  
  10.   ["required_num_args"]=>  
  11.   int(0)  
  12.   ["pass_rest_by_reference"]=>  
  13.   bool(false)  
  14.   ["line_start"]=>  
  15.   int(0)  
  16.   ["line_end"]=>  
  17.   int(0)  
  18.   ["return_reference"]=>  
  19.   bool(false)  
  20.   ["refcount"]=>  
  21.   int(1)  
  22.   ["last"]=>  
  23.   int(3)  
  24.   ["size"]=>  
  25.   int(3)  
  26.   ["T"]=>  
  27.   int(1)  
  28.   ["last_brk_cont"]=>  
  29.   int(0)  
  30.   ["current_brk_cont"]=>  
  31.   int(-1)  
  32.   ["backpatch_count"]=>  
  33.   int(0)  
  34.   ["done_pass_two"]=>  
  35.   bool(true)  
  36.   ["filename"]=>  
  37.   string(17) "Parsekit Compiler"  
  38.   ["opcodes"]=>  
  39.   array(3) {  
  40.     [0]=>  
  41.     array(7) {  
  42.       ["address"]=>  
  43.       int(536780564)  
  44.       ["opcode"]=>  
  45.       int(41)  
  46.       ["opcode_name"]=>  
  47.       string(10) "ZEND_PRINT"  
  48.       ["flags"]=>  
  49.       int(770)  
  50.       ["result"]=>  
  51.       array(3) {  
  52.         ["type"]=>  
  53.         int(2)  
  54.         ["type_name"]=>  
  55.         string(10) "IS_TMP_VAR"  
  56.         ["var"]=>  
  57.         int(0)  
  58.       }  
  59.       ["op1"]=>  
  60.       array(3) {  
  61.         ["type"]=>  
  62.         int(1)  
  63.         ["type_name"]=>  
  64.         string(8) "IS_CONST"  
  65.         ["constant"]=>  
  66.         &string(10) "hello word"  
  67.       }  
  68.       ["lineno"]=>  
  69.       int(1)  
  70.     }  
  71.     [1]=>  
  72.     array(7) {  
  73.       ["address"]=>  
  74.       int(536780684)  
  75.       ["opcode"]=>  
  76.       int(70)  
  77.       ["opcode_name"]=>  
  78.       string(9) "ZEND_FREE"  
  79.       ["flags"]=>  
  80.       int(271104)  
  81.       ["op1"]=>  
  82.       array(4) {  
  83.         ["type"]=>  
  84.         int(2)  
  85.         ["type_name"]=>  
  86.         string(10) "IS_TMP_VAR"  
  87.         ["var"]=>  
  88.         int(0)  
  89.         ["EA.type"]=>  
  90.         int(0)  
  91.       }  
  92.       ["op2"]=>  
  93.       array(3) {  
  94.         ["type"]=>  
  95.         int(8)  
  96.         ["type_name"]=>  
  97.         string(9) "IS_UNUSED"  
  98.         ["opline_num"]=>  
  99.         string(1) "0"  
  100.       }  
  101.       ["lineno"]=>  
  102.       int(1)  
  103.     }  
  104.     [2]=>  
  105.     array(7) {  
  106.       ["address"]=>  
  107.       int(536780804)  
  108.       ["opcode"]=>  
  109.       int(62)  
  110.       ["opcode_name"]=>  
  111.       string(11) "ZEND_RETURN"  
  112.       ["flags"]=>  
  113.       int(16777984)  
  114.       ["op1"]=>  
  115.       array(3) {  
  116.         ["type"]=>  
  117.         int(1)  
  118.         ["type_name"]=>  
  119.         string(8) "IS_CONST"  
  120.         ["constant"]=>  
  121.         &NULL  
  122.       }  
  123.       ["extended_value"]=>  
  124.       int(0)  
  125.       ["lineno"]=>  
  126.       int(1)  
  127.     }  
  128.   }  
  129. }  
总结: 两种方法 1.如果要查看单句php的opcode

# /usr/local/php/bin/php -r "var_dump(parsekit_compile_string('print 1+1;'));"

参考 http://www.php.net/manual/zh/function.parsekit-compile-string.php


2.如果要查看网站下某个php文件的opcode

参考  http://www.php.net/manual/zh/function.parsekit-compile-file.php

# /usr/local/php/bin/php -r "var_dump(parsekit_compile_file('/var/www/tb.php'));"

 

3.如果要查看某个函数的opcode

参考 http://www.php.net/manual/zh/function.parsekit-func-arginfo.php

<?php
function foo($barstdClass $baz, &$bomb$bling false) {
}

var_dump(parsekit_func_arginfo('foo'));
?>


也可以通过VLD查看,具体请看本人写的http://blog.youkuaiyun.com/21aspnet/article/details/7002644

 

安装parsekit扩展

http://pecl.php.net/package/parsekit

下载最新的

#wget http://pecl.php.net/get/parsekit-1.3.0.tgz

安装过程省略

可以参考  本人写的http://blog.youkuaiyun.com/21aspnet/article/details/7035392  安装apc扩展是一样的原理

还是自动安装很方便

安装:

# /usr/local/PHP/bin/pecl install parsekit     

配置:

php.ini加extension=parsekit.so    

重启:

# /usr/local/apache2/bin/apachectl restart  

测试:

# /usr/local/php/bin/php -r "var_dump(parsekit_compile_string('print 1+1;'));"

输出:

[html]  view plain  copy
  1. array(19) {  
  2.   ["type"]=>  
  3.   int(4)  
  4.   ["type_name"]=>  
  5.   string(14) "ZEND_EVAL_CODE"  
  6.   ["fn_flags"]=>  
  7.   int(0)  
  8.   ["num_args"]=>  
  9.   int(0)  
  10.   ["required_num_args"]=>  
  11.   int(0)  
  12.   ["pass_rest_by_reference"]=>  
  13.   bool(false)  
  14.   ["line_start"]=>  
  15.   int(0)  
  16.   ["line_end"]=>  
  17.   int(0)  
  18.   ["return_reference"]=>  
  19.   bool(false)  
  20.   ["refcount"]=>  
  21.   int(1)  
  22.   ["last"]=>  
  23.   int(4)  
  24.   ["size"]=>  
  25.   int(4)  
  26.   ["T"]=>  
  27.   int(2)  
  28.   ["last_brk_cont"]=>  
  29.   int(0)  
  30.   ["current_brk_cont"]=>  
  31.   int(-1)  
  32.   ["backpatch_count"]=>  
  33.   int(0)  
  34.   ["done_pass_two"]=>  
  35.   bool(true)  
  36.   ["filename"]=>  
  37.   string(17) "Parsekit Compiler"  
  38.   ["opcodes"]=>  
  39.   array(4) {  
  40.     [0]=>  
  41.     array(8) {  
  42.       ["address"]=>  
  43.       int(457076436)  
  44.       ["opcode"]=>  
  45.       int(1)  
  46.       ["opcode_name"]=>  
  47.       string(8) "ZEND_ADD"  
  48.       ["flags"]=>  
  49.       int(197378)  
  50.       ["result"]=>  
  51.       array(3) {  
  52.         ["type"]=>  
  53.         int(2)  
  54.         ["type_name"]=>  
  55.         string(10) "IS_TMP_VAR"  
  56.         ["var"]=>  
  57.         int(0)  
  58.       }  
  59.       ["op1"]=>  
  60.       array(3) {  
  61.         ["type"]=>  
  62.         int(1)  
  63.         ["type_name"]=>  
  64.         string(8) "IS_CONST"  
  65.         ["constant"]=>  
  66.         &int(1)  
  67.       }  
  68.       ["op2"]=>  
  69.       array(3) {  
  70.         ["type"]=>  
  71.         int(1)  
  72.         ["type_name"]=>  
  73.         string(8) "IS_CONST"  
  74.         ["constant"]=>  
  75.         &int(1)  
  76.       }  
  77.       ["lineno"]=>  
  78.       int(1)  
  79.     }  
  80.     [1]=>  
  81.     array(7) {  
  82.       ["address"]=>  
  83.       int(457076556)  
  84.       ["opcode"]=>  
  85.       int(41)  
  86.       ["opcode_name"]=>  
  87.       string(10) "ZEND_PRINT"  
  88.       ["flags"]=>  
  89.       int(770)  
  90.       ["result"]=>  
  91.       array(3) {  
  92.         ["type"]=>  
  93.         int(2)  
  94.         ["type_name"]=>  
  95.         string(10) "IS_TMP_VAR"  
  96.         ["var"]=>  
  97.         int(1)  
  98.       }  
  99.       ["op1"]=>  
  100.       array(3) {  
  101.         ["type"]=>  
  102.         int(2)  
  103.         ["type_name"]=>  
  104.         string(10) "IS_TMP_VAR"  
  105.         ["var"]=>  
  106.         int(0)  
  107.       }  
  108.       ["lineno"]=>  
  109.       int(1)  
  110.     }  
  111.     [2]=>  
  112.     array(7) {  
  113.       ["address"]=>  
  114.       int(457076676)  
  115.       ["opcode"]=>  
  116.       int(70)  
  117.       ["opcode_name"]=>  
  118.       string(9) "ZEND_FREE"  
  119.       ["flags"]=>  
  120.       int(271104)  
  121.       ["op1"]=>  
  122.       array(4) {  
  123.         ["type"]=>  
  124.         int(2)  
  125.         ["type_name"]=>  
  126.         string(10) "IS_TMP_VAR"  
  127.         ["var"]=>  
  128.         int(1)  
  129.         ["EA.type"]=>  
  130.         int(0)  
  131.       }  
  132.       ["op2"]=>  
  133.       array(3) {  
  134.         ["type"]=>  
  135.         int(8)  
  136.         ["type_name"]=>  
  137.         string(9) "IS_UNUSED"  
  138.         ["opline_num"]=>  
  139.         string(1) "0"  
  140.       }  
  141.       ["lineno"]=>  
  142.       int(1)  
  143.     }  
  144.     [3]=>  
  145.     array(7) {  
  146.       ["address"]=>  
  147.       int(457076796)  
  148.       ["opcode"]=>  
  149.       int(62)  
  150.       ["opcode_name"]=>  
  151.       string(11) "ZEND_RETURN"  
  152.       ["flags"]=>  
  153.       int(16777984)  
  154.       ["op1"]=>  
  155.       array(3) {  
  156.         ["type"]=>  
  157.         int(1)  
  158.         ["type_name"]=>  
  159.         string(8) "IS_CONST"  
  160.         ["constant"]=>  
  161.         &NULL  
  162.       }  
  163.       ["extended_value"]=>  
  164.       int(0)  
  165.       ["lineno"]=>  
  166.       int(1)  
  167.     }  
  168.   }  
  169. }  


 

 再看输出hello word

# /usr/local/php/bin/php -r "var_dump(parsekit_compile_string('print \"hello word\";'));"

输出:

 

[html]  view plain  copy
  1. array(19) {  
  2.   ["type"]=>  
  3.   int(4)  
  4.   ["type_name"]=>  
  5.   string(14) "ZEND_EVAL_CODE"  
  6.   ["fn_flags"]=>  
  7.   int(0)  
  8.   ["num_args"]=>  
  9.   int(0)  
  10.   ["required_num_args"]=>  
  11.   int(0)  
  12.   ["pass_rest_by_reference"]=>  
  13.   bool(false)  
  14.   ["line_start"]=>  
  15.   int(0)  
  16.   ["line_end"]=>  
  17.   int(0)  
  18.   ["return_reference"]=>  
  19.   bool(false)  
  20.   ["refcount"]=>  
  21.   int(1)  
  22.   ["last"]=>  
  23.   int(3)  
  24.   ["size"]=>  
  25.   int(3)  
  26.   ["T"]=>  
  27.   int(1)  
  28.   ["last_brk_cont"]=>  
  29.   int(0)  
  30.   ["current_brk_cont"]=>  
  31.   int(-1)  
  32.   ["backpatch_count"]=>  
  33.   int(0)  
  34.   ["done_pass_two"]=>  
  35.   bool(true)  
  36.   ["filename"]=>  
  37.   string(17) "Parsekit Compiler"  
  38.   ["opcodes"]=>  
  39.   array(3) {  
  40.     [0]=>  
  41.     array(7) {  
  42.       ["address"]=>  
  43.       int(536780564)  
  44.       ["opcode"]=>  
  45.       int(41)  
  46.       ["opcode_name"]=>  
  47.       string(10) "ZEND_PRINT"  
  48.       ["flags"]=>  
  49.       int(770)  
  50.       ["result"]=>  
  51.       array(3) {  
  52.         ["type"]=>  
  53.         int(2)  
  54.         ["type_name"]=>  
  55.         string(10) "IS_TMP_VAR"  
  56.         ["var"]=>  
  57.         int(0)  
  58.       }  
  59.       ["op1"]=>  
  60.       array(3) {  
  61.         ["type"]=>  
  62.         int(1)  
  63.         ["type_name"]=>  
  64.         string(8) "IS_CONST"  
  65.         ["constant"]=>  
  66.         &string(10) "hello word"  
  67.       }  
  68.       ["lineno"]=>  
  69.       int(1)  
  70.     }  
  71.     [1]=>  
  72.     array(7) {  
  73.       ["address"]=>  
  74.       int(536780684)  
  75.       ["opcode"]=>  
  76.       int(70)  
  77.       ["opcode_name"]=>  
  78.       string(9) "ZEND_FREE"  
  79.       ["flags"]=>  
  80.       int(271104)  
  81.       ["op1"]=>  
  82.       array(4) {  
  83.         ["type"]=>  
  84.         int(2)  
  85.         ["type_name"]=>  
  86.         string(10) "IS_TMP_VAR"  
  87.         ["var"]=>  
  88.         int(0)  
  89.         ["EA.type"]=>  
  90.         int(0)  
  91.       }  
  92.       ["op2"]=>  
  93.       array(3) {  
  94.         ["type"]=>  
  95.         int(8)  
  96.         ["type_name"]=>  
  97.         string(9) "IS_UNUSED"  
  98.         ["opline_num"]=>  
  99.         string(1) "0"  
  100.       }  
  101.       ["lineno"]=>  
  102.       int(1)  
  103.     }  
  104.     [2]=>  
  105.     array(7) {  
  106.       ["address"]=>  
  107.       int(536780804)  
  108.       ["opcode"]=>  
  109.       int(62)  
  110.       ["opcode_name"]=>  
  111.       string(11) "ZEND_RETURN"  
  112.       ["flags"]=>  
  113.       int(16777984)  
  114.       ["op1"]=>  
  115.       array(3) {  
  116.         ["type"]=>  
  117.         int(1)  
  118.         ["type_name"]=>  
  119.         string(8) "IS_CONST"  
  120.         ["constant"]=>  
  121.         &NULL  
  122.       }  
  123.       ["extended_value"]=>  
  124.       int(0)  
  125.       ["lineno"]=>  
  126.       int(1)  
  127.     }  
  128.   }  
  129. }  
总结: 两种方法 1.如果要查看单句php的opcode

# /usr/local/php/bin/php -r "var_dump(parsekit_compile_string('print 1+1;'));"

参考 http://www.php.net/manual/zh/function.parsekit-compile-string.php


2.如果要查看网站下某个php文件的opcode

参考  http://www.php.net/manual/zh/function.parsekit-compile-file.php

# /usr/local/php/bin/php -r "var_dump(parsekit_compile_file('/var/www/tb.php'));"

 

3.如果要查看某个函数的opcode

参考 http://www.php.net/manual/zh/function.parsekit-func-arginfo.php

<?php
function foo($barstdClass $baz, &$bomb$bling false) {
}

var_dump(parsekit_func_arginfo('foo'));
?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值