I have a PHP app "index.php" that, for various reasons, needs to run other PHP scripts by using include_once on that other script. That other script isn't very stable, so is there some way to do a safe include_once that won't halt the caller?

我有一个PHP应用程序“index.php”,由于各种原因,需要通过在其他脚本上使用include_once来运行其他PHP脚本。那个其他脚本不是很稳定,那么有没有办法做一个不会停止调用者的安全include_once?

i.e.:

<?php

safely_include_once('badfile.php'); // MAY throw syntax error, parse error, other badness
echo "I can continue execution after error";

?>

(I know what a bad idea this can be, etc., rest assured this isn't production-environment stuff.)

(我知道这可能是个坏主意,等等,请放心,这不是生产环境的东西。)

8 个解决方案

#1


6

You can just

你可以

@include "fileWithBadSyntax.php";

Which, from my quick tests, works for both parse errors or errors thrown with trigger_error().

从我的快速测试中,它适用于解析错误或使用trigger_error()抛出的错误。

EDIT: This is completely wrong. See sneak's answer, which is correct, if somewhat unhelpful.

编辑:这是完全错误的。看看潜行的答案,这是正确的,如果有点无益的话。

更多相关文章

  1. PHP基础之脚本传参
  2. phpBB3导入帖子的Python脚本
  3. 您是否认为PHP中的错误形式是在类方法中访问超级全局变量?
  4. 解析错误:语法错误,第12行/home/public_html/gigs.html中的意外T_L
  5. PHP脚本在我的Wordpress文件中。请解码或帮助我删除它。
  6. eclipse 编写php错误
  7. 我无法定义我的错误
  8. php中的错误级别
  9. fgetcsv()错误地将双引号添加到第一行的第一个元素

随机推荐

  1. Android及系统架构目录结构介绍
  2. android实现gif图与文字混排
  3. Android(安卓)WindowManager悬浮窗:不需要
  4. Android布局自定义Shap圆形ImageView,可以
  5. android解析xml文件的方式(其一)
  6. Android开发者已经度过了初级吗
  7. Fedora 下配置 Android 开发环境
  8. Android(安卓)listview与adapter用法
  9. Android(安卓)Fragment 真正的完全解析(下
  10. Android面试系列文章2018之Android部分之