Is there any way to make php stop processing a file and make it just work with the part it already parsed. I mean like this:
<some data here> <?php phpinfo(); [IS THERE ANY THING I CAN PUT HERE] ?> <more data> [IS THERE ANY THING I CAN PUT HERE] <?HOW CAN I MAKE PHP NOT PARSE THIS?>
is there anyway to make php ignore data after the first php part?
Another solution might be to use
Halts the execution of the compiler.
This can be useful to embed data in
PHP scripts, like the installation
Byte position of the data start can be
determined by the
which is defined only if there is a
__halt_compiler()presented in the
A typical usage is for Phar archives, when you need to embed PHP and (possibly binary) data into a single file, and the PHP code needs to have access to that data.
And there is actually a difference : this code :
blah blah <?php phpinfo(); ?> glop glop <?php exit(); ?> <?HOW CAN I MAKE PHP NOT PARSE THIS?>
Gets me a
Parse error: syntax error, unexpected T_STRING
(Probably because I have
short_open_tag enabled, I suppose)
While this one :
blah blah <?php phpinfo(); ?> glop glop <?php __halt_compiler(); ?> <?HOW CAN I MAKE PHP NOT PARSE THIS?>
works OK — this invalid PHP code being after the call to
I believe that all you need to do is to write
return 0; (or any other value), PHP will stop parsing this file and return to whatever invoked it. This is useful when you need to stop execution in one file but would not like to
You can use the
exit keyword to tell PHP to finish processing the file.