PHP包含解析错误的文件 [英] PHP include files with parse errors

查看:93
本文介绍了PHP包含解析错误的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个动态生成的PHP文件,包含在其他PHP脚本中(通过include)。当使用解析错误生成第一个(出于某些不明原因)时,导致主脚本解析错误停止执行。



有没有办法检测包含文件时解析错误,以便我可以动态重新生成该文件?

解决方案

您可以运行PHP的命令行版本来检查语法:

  php -l filename 

如果需要检查PHP脚本中的语法,请使用 exec()函数来调用命令行程序。 / p>

另请参阅已弃用的函数 php_check_syntax()


I've got an dynamically-generated PHP file that is included (via include) in other PHP script. When the first one (for some obscure reason) is generated with parse-errors, causes the main script parse-error an stop the execution.

Is there any way to detect parse errors when including a file so I can regenerate dynamically that file?

解决方案

You can run the command line version of PHP to check the syntax:

php -l filename

If you need to check the syntax from within the PHP script, use the exec() function to call the command line program.

See also the deprecated function php_check_syntax()

这篇关于PHP包含解析错误的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆