Php miscellaneous functions (MISC) _ halt_compiler ()

Source: Internet
Author: User
This is a function that I have never used. Most people do not need to use this function, so few people know its usefulness. Today, I read some related knowledge on stackoverflow and share it with you. Let's take a look at the official explanation: interrupt the execution of the compiler. It is often used to embed data in PHP scripts, similar to installation files. You can use constant _ COM

This is a function that I have never used. Most people do not need to use this function, so few people know its usefulness. Today, I read some related knowledge on stackoverflow and share it with you. Let's take a look at the official explanation: interrupt the execution of the compiler. It is often used to embed data in PHP scripts, similar to installation files. You can use constant _ COM

This is a function that I have never used. Most people do not need to use this function, so few people know its usefulness. Today, I read some related knowledge on stackoverflow and share it with you.
First look at the official explanation:

Interrupt the execution of the compiler. It is often used to embed data in PHP scripts, similar to installation files.
You can use the constant _ COMPILER_HALT_OFFSET _ to obtain the position of the Start byte of the data. The constant is only defined in the file where _ halt_compiler is used.

Let's look at the code at both ends and their running results:

Vagrant @ precise64:/var/www/test/misc $ cat exit. php
 

See the difference!
Both the exit () and _ halt_compiler () Methods exit code execution, but the file using exit () will be interpreted as the end of the file. If a syntax error occurs, an error will be reported, __halt_compiler () will not explain the subsequent code. Therefore, you can add anything you want (such as your bank card account and password) after _ halt_compiler () without thinking about the syntax.

In the file where _ halt_compiler () appears, a variable _ COMPILER_HALT_OFFSET __is generated. The value is the next character at the location where the code is interrupted, it is officially referred to as "the location of the Data start Byte ";
See the following code:

Vagrant @ precise64:/var/www/test/misc $ cat halt_compile.php
  

Use the fseek method to directly move to the starting position of "the installation data (eg. tar, gz, PHP, etc.)" and then read the content.

Original article address: php miscellaneous functions (MISC) _ halt_compiler (). Thank you for sharing it with me.

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.