E_STRICT
这个缺点是PHP5之后惹人的,你的代码可以运行,然则不是PHP建议的写法。
本来会出现两次NOTICE的,然则如今,只会出现一次了…
比如在函数形参传递++符号
- // Strict Standards: Only variables should be passed by reference in /tmp/php/index.php on line 17
- function change (&$var) {
- $var += 10;
- }
- $var = 1;
- change(++$var);
- // E_STRICT
E_RECOVERABLE_ERROR
E_PARSE
这个级别其实是ERROR级其余,然则它是期望被捕获的,如不雅没有被缺点处理捕获,表示和E_ERROR是一样的。
经常涌如今形参定义潦攀类型,但调用的时刻传入了缺点类型。它的缺点提示也比E_ERROR的fatal error前面多了一个Catachable的字样。
- //Catchable fatal error: Argument 1 passed to testCall() must be an instance of A, instance of B given, called in /tmp/php/index.php on line 37 and defined in /tmp/php/index.php on line 33
- class A {
- }
- class B {
- }
- function testCall(A $a) {
- }
- $b = new B();
- testCall($b);
E_DEPRECATED
这个缺点表示你用了一个旧版本的函数,而这个函数后期版本可能被禁用或者不保护了。
比如curl的CURLOPT_POSTFIELDS应用@FILENAME来上传文件的办法
比如$b变量不存在,我们把它赋值给别的一个变量
- // Deprecated: curl_setopt(): The usage of the @filename API for file uploading is deprecated. Please use the CURLFile class instead in /tmp/php/index.php on line 42
- $ch = curl_init("http://www.remotesite.com/upload.php");
- curl_setopt($ch, CURLOPT_POSTFIELDS, array('fileupload' => '@'. "test"));
E_CORE_ERROR, E_CORE_WARNING
这两个缺点是由PHP的引擎产生的,在PHP初始化过程中产生。
E_COMPILE_ERROR, E_COMPILE_WARNING
E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE, E_USER_DEPRECATED,
推荐阅读
1、“VS Code 师出 VS,是 VS 找了一群仁攀来重写的,复竽暌姑了很多 VS 的代码,等等“。 本文作者 rebomix 是微软重要的开源项目之一 Visual Studio Code (常简称 VS Code)的保>>>详细阅读
本文标题:关于PHP的错误机制总结
地址:http://www.17bianji.com/lsqh/34989.html
1/2 1