加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

停止php处理文件

发布时间:2020-12-13 18:21:43 所属栏目:PHP教程 来源:网络整理
导读:有没有办法让php停止处理文件并让它只与它已经解析的部分一起工作.我的意思是这样的: 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? 无论如何,在
有没有办法让php停止处理文件并让它只与它已经解析的部分一起工作.我的意思是这样的:
<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?>

无论如何,在第一个PHP部分之后让php忽略数据?

另一种解决方案可能是使用 __halt_compiler

Halts the execution of the compiler.
This can be useful to embed data in
PHP scripts,like the installation
files.

Byte position of the data start can be
determined by the
__COMPILER_HALT_OFFSET__ constant
which is defined only if there is a
__halt_compiler() presented in the
file.

典型用法是Phar archives,当您需要将PHP和(可能是二进制)数据嵌入到单个文件中时,PHP代码需要能够访问该数据.

实际上有一点不同:这段代码:

blah blah
<?php phpinfo(); ?>
glop glop
<?php exit(); ?>
<?HOW CAN I MAKE PHP NOT PARSE THIS?>

给我一个Parse错误:语法错误,意外的T_STRING
(可能是因为我启用了short_open_tag,我想)

这一个:

blah blah
<?php phpinfo(); ?>
glop glop
<?php __halt_compiler(); ?>
<?HOW CAN I MAKE PHP NOT PARSE THIS?>

工作正常 – 这个无效的PHP代码在调用__halt_compiler()之后.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读