PHP Source Code Analysis

Source: Internet
Author: User

wget http://pecl.php.net/get/vld-0.11.2.tgz
Tar zxf vld-0.11.2.tgz
CD vld-0.11.2
Which phpize
/usr/bin/phpize
Find/-name ' Php-config '
/usr/bin/php-config
./configure--with-php-config=/usr/bin/php-config--ENABLE-VLD
echo $?
Make && make install
ll/usr/lib64/php/modules/

VI php.ini
Extension=vld.so

/ETC/INIT.D/PHP-FPM restart
View Phpinfo ()
==================== Case:
VI demo.php
$a = ' Hello World ';
echo $a;

===================== Source Analysis:
[Email protected] yeqing]# php-dvld.active=1./demo.php
Finding entry points
Branch analysis from position:0
Return found
FileName:/home/yeqing/demo.php
Function name: (NULL)
Number of Ops:3
Compiled VARs:!0 = $a
Line # * OP fetch ext return operands
---------------------------------------------------------------------------------
2 0 > ASSIGN! 0, ' hello+world%21%21 '
3 1 ECHO!0
6 2 > RETURN 1

Branch: # 0; line:2-6; sop:0; Eop:2
Path #1:0,
Hello world!!
================
Line number, opcodes instruction number, script start tag, end tag, ZEND VM instruction, return value, ZEND VM directive parameter

Opcodes Manual:
http://php.net/manual/en/internals2.opcodes.list.php



================ the information for the intermediate code generated on the PHP code output for VLD, as described below
Branch analysis from position this information is used when analyzing arrays.
Return found whether it returns, this basically has all.
FileName parsed by file name
function name, for each function VLD generates a separate piece of information, which shows the name of the current function.
Number of OPS generated operands
Compiled VARs the variables during compilation, which are added after PHP5, which is a cache optimization. Such variables are marked with IS_CV in the PHP source code.
List of variables for the intermediate code generated by the OP list

Use the-dvld.active parameter to output the VLD default settings, if you want to see more detailed content. You can use the-dvld.verbosity parameter.

Php-dvld.active=1-dvld.verbosity=3 demo.php
which
-dvld.verbosity=3 is the most detailed information that VLD can display in the current version

If we just want to see the intermediate code of the output and do not want to execute this PHP code, you can use-dvld.execute=0 to disable the execution of the Code
Php-dvld.active=1-dvld.execute=0 demo.php


Read the source to learn a spirit: the Clues
Reference Documentation:
Http://www.php-internals.com/book/?p=C-php-vld
Http://www.php-internals.com/book/?p=chapt02/02-03-02-opcode
http://php.net/manual/zh/internals2.ze1.zendapi.php
Http://www.laruence.com/2011/03/04/1894.html
Http://blog.pureisle.net/archives/2294.html
http://www.imsiren.com/archives/704
http://blog.csdn.net/siren0203/article/details/8085813
Http://www.cnblogs.com/miao-zp/p/6374311.html

This article from the "Development and operation of the" blog, declined to reprint!

PHP Source Code Analysis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.