使用PHP opcodes看$php与”$php”的区别
使用PHP opcodes看$php与”$php”的区别
# 首先下载最新版vld扩展: wget http://pecl.php.net/get/vld-0.11.2.tgz tar zxvf vld-0.11.2.tgz cd vld-0.11.2/ phpize5 ./configure make sudo make install # Installing shared extensions: /usr/lib/php5/20100525+lfs/ |
修改cli的配置文件激活vld扩展
/etc/php5/cli/php.ini
添加一行
extension=vld.so
测试开始
qiufeng@ubuntu:~$ php -dvld.active=1 -r 'echo @$php;' Finding entry points Branch analysis from position: 0 Return found filename: Command line code function name: (null) number of ops: 5 compiled vars: none line # * op fetch ext return operands --------------------------------------------------------------------------------- 1 0 > BEGIN_SILENCE ~0 1 FETCH_R local $1 'php' 2 END_SILENCE ~0 3 ECHO $1 4 > RETURN null branch: # 0; line: 1- 1; sop: 0; eop: 4 path #1: 0,
BEGIN_SILENCE 屏蔽错误消息代码片段的起始符
FETCH_R 获取变量名
END_SILENCE 屏蔽错误消息代码片段的结束符
ECHO 打印文本
RETURN 来自函数中的返回值
qiufeng@ubuntu:~$ php -dvld.active=1 -r 'echo @"$php";' Finding entry points Branch analysis from position: 0 Return found filename: Command line code function name: (null) number of ops: 6 compiled vars: none line # * op fetch ext return operands --------------------------------------------------------------------------------- 1 0 > BEGIN_SILENCE ~0 1 FETCH_R local $1 'php' 2 ADD_VAR ~2 $1 3 END_SILENCE ~0 4 ECHO ~2 5 > RETURN null branch: # 0; line: 1- 1; sop: 0; eop: 5 path #1: 0,
多了ADD_VAR,这是一个赋值语句。 由于使用了”$php”语法,需要添加一个临时变量来存储结果。