Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

If you install and use vld to view the opcode code of php

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "if you install and use vld to view the opcode code of php", the content is easy to understand, clear, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn "if you install and use vld to view php's opcode code" this article.

Which is better if you need to analyze the performance of PHP code, or code that implements the same functionality? Or if you want to know the underlying implementation, you can use VLD to view opcode.

Download and install VLD

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

# tar zxvf vld-0.11.2.tgz

# cd. / vld-0.11.2

# / usr/local/php/bin/phpize or direct phpize

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

# make & & make install

-

Edit the php.ini file to activate the vld extension:

Php.ini location

# cd / usr/local/php/lib

Increase

Extension=vld.so

Restart Apache:

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

-

View phpinfo () information

-

At this point, VLD is installed. Write a simple test.php

# php-dvld.active=1. / test.php

If the php environment variable is not set

View the result

# php-dvld.active=1. / test.php

If the php environment variable is not set

View the result

The information of the intermediate code generated for the PHP code output by VLD is described as follows:

The information Branch analysis from position is often used when analyzing arrays.

Whether Return found returns or not, there are basically all of them.

The file name of the filename analysis

The name of the function name function. For each function VLD, a separate message is generated as above. The name of the current function is shown here.

Operands generated by number of ops

Variables during compiled vars compilation, which are added after PHP5, is a cache optimization. Such variables are marked with IS_CV in the PHP source code.

A list of variables for intermediate code generated by op list

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

# php-dvld.active=1-dvld.verbosity=3 text.php

-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, we can use-dvld.execute=0 to disable the execution of the code

# php-dvld.active=1-dvld.execute=0 text.php

Parameter list for VLD extension:

-whether dvld.active activates the VLD hook when executing PHP. The default is 0, which means disabled. It can be enabled using-dvld.active=1.

-whether dvld.skip_prepend skips the files specified by auto_prepend_file in the php.ini configuration file. The default is 0, that is, the included files are not skipped and the intermediate code generated by the code in these included files is displayed. This parameter takes effect on a prerequisite:-dvld.execute=0

-whether dvld.skip_append skips the files specified by auto_append_file in the php.ini configuration file. The default is 0, that is, the included files are not skipped and the intermediate code generated by the code in these included files is displayed. This parameter takes effect on a prerequisite:-dvld.execute=0

-whether dvld.execute executes this PHP script. The default value is 1, which means execution. You can use-dvld.execute=0 to indicate that only the intermediate code is displayed and the generated intermediate code is not executed.

-whether dvld.format is displayed in a custom format. Default is 0, which means no. You can use-dvld.format=1 to indicate that it is displayed in a format you define. The custom format output here is at the parameter interval specified by-dvld.col_sep

-dvld.col_sep this function is not valid until the-dvld.format parameter is enabled, which defaults to "\ t".

-whether dvld.verbosity displays more detailed information, the default is 1, and its value can be 0, 1, 2, and 3 is actually smaller than 0, but the effect is the same as 0, such as 0.1, except for negative numbers, negative numbers and effects are as large as 3, but the effect is the same as 3.

-dvld.save_dir specifies the path to the file output, and the default path is / tmp.

-dvld.save_paths controls whether to export files. Default is 0, which means no files are exported.

-dvld.dump_paths controls the output content. Now there are only 0 and 1 cases. Default is 1. Output content

Use VLD to compare code differences

Code text1.php

[php] view plain copy

$var = 111

$str = "AAA". $var. "BBB"

Code text2.php

[php] view plain copy

$var = 111

$str = "AAA $var BBB"

The above is all the contents of this article "if you install and use vld to view the opcode code of php", thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 266

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report