PHP 的缺点机制也是异常复杂的,做了几年php,也没有细心总结过,如今就补上这一课。
特别解释:文┞仿的PHP版本应用5.5.32
PHP的缺点级别
起首须要懂得php有哪些缺点。截至到php5.5,一共有16个缺点级别
留意:测验测验下面的代码的时刻请确保打开error_log:
- error_reporting(E_ALL);
- ini_set('display_errors', 'On');
E_ERROR
这种缺点是致命缺点,会在页面显示Fatal Error, 当出现这种缺点的时刻,法度榜样就无法持续履行下去了
缺点示例:
- // Fatal error: Call to undefined function hpinfo() in /tmp/php/index.php on line 5
- hpinfo(); //E_ERROR
留意,如不雅有未被捕获的异常,也是会触发这个级其余。
- // Fatal error: Uncaught exception 'Exception' with message 'test exception' in /tmp/php/index.php:5 Stack trace: #0 {main} thrown in /tmp/php/index.php on line 5
- throw new Exception("test exception");
E_WARNING
这种缺点只是警告,不会终止脚本,法度榜样还会持续进行,显示的缺点信息是Warning。比如include一个不存在的文件。
- //Warning: include(a.php): failed to open stream: No such file or directory in /tmp/php/index.php on line 7
- //Warning: include(): Failed opening 'a.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /tmp/php/index.php on line 7
- include("a.php"); //E_WARNING
E_NOTICE
这种缺点程度更为稍微一些,提示你这个处所不该该这么写。这个也是运行时缺点,这个缺点的代码可能在其他处所没有问题,只是在当前高低文情况下出现了问题。
- //Notice: Undefined variable: b in /tmp/php/index.php on line 9
- $a = $b; //E_NOTICE
display_errors是控制是否要在标准输出展示缺点信息
比如下面的z没有设置为变量。
这两个缺点是由PHP引擎产生的,在编译过程中产生。
- // Parse error: syntax error, unexpected '=' in /tmp/php/index.php on
推荐阅读
1、“VS Code 师出 VS,是 VS 找了一群仁攀来重写的,复竽暌姑了很多 VS 的代码,等等“。 本文作者 rebomix 是微软重要的开源项目之一 Visual Studio Code (常简称 VS Code)的保>>>详细阅读
本文标题:关于PHP的错误机制总结
地址:http://www.17bianji.com/lsqh/34989.html
1/2 1