{"id":3583,"date":"2016-04-21T11:14:37","date_gmt":"2016-04-21T03:14:37","guid":{"rendered":"http:\/\/www.wpadmin.cn\/blog\/?p=3583"},"modified":"2016-04-21T11:14:37","modified_gmt":"2016-04-21T03:14:37","slug":"php%e7%9a%84%e9%94%99%e8%af%af%e6%9c%ba%e5%88%b6%e6%80%bb%e7%bb%93","status":"publish","type":"post","link":"https:\/\/www.wpadmin.cn\/blog\/3583.html","title":{"rendered":"PHP\u7684\u9519\u8bef\u673a\u5236\u603b\u7ed3"},"content":{"rendered":"<h1 id=\"php\u7684\u9519\u8bef\u673a\u5236\u603b\u7ed3\">PHP\u7684\u9519\u8bef\u673a\u5236\u603b\u7ed3<\/h1>\n<p>PHP\u7684\u9519\u8bef\u673a\u5236\u4e5f\u662f\u975e\u5e38\u590d\u6742\u7684\uff0c\u505a\u4e86\u51e0\u5e74php\uff0c\u4e5f\u6ca1\u6709\u4ed4\u7ec6\u603b\u7ed3\u8fc7\uff0c\u73b0\u5728\u5c31\u8865\u4e0a\u8fd9\u4e00\u8bfe\u3002<\/p>\n<p>\u7279\u522b\u8bf4\u660e\uff1a\u6587\u7ae0\u7684PHP\u7248\u672c\u4f7f\u75285.5.32<\/p>\n<h1 id=\"php\u7684\u9519\u8bef\u7ea7\u522b\">PHP\u7684\u9519\u8bef\u7ea7\u522b<\/h1>\n<p>\u9996\u5148\u9700\u8981\u4e86\u89e3php\u6709\u54ea\u4e9b\u9519\u8bef\u3002\u622a\u81f3\u5230php5.5\uff0c\u4e00\u5171\u6709<a href=\"http:\/\/php.net\/manual\/zh\/errorfunc.constants.php\">16\u4e2a\u9519\u8bef\u7ea7\u522b<\/a><\/p>\n<p>\u6ce8\u610f\uff1a\u5c1d\u8bd5\u4e0b\u9762\u7684\u4ee3\u7801\u7684\u65f6\u5019\u8bf7\u786e\u4fdd\u6253\u5f00error_log:<\/p>\n<pre><code class=\"hljs lisp\">error_reporting(<span class=\"hljs-name\">E_ALL<\/span>)<span class=\"hljs-comment\">;<\/span>\r\nini_set('display_errors', 'On')<span class=\"hljs-comment\">;<\/span><\/code><\/pre>\n<h2 id=\"e_error\">E_ERROR<\/h2>\n<p>\u8fd9\u79cd\u9519\u8bef\u662f\u81f4\u547d\u9519\u8bef\uff0c\u4f1a\u5728\u9875\u9762\u663e\u793aFatal Error\uff0c \u5f53\u51fa\u73b0\u8fd9\u79cd\u9519\u8bef\u7684\u65f6\u5019\uff0c\u7a0b\u5e8f\u5c31\u65e0\u6cd5\u7ee7\u7eed\u6267\u884c\u4e0b\u53bb\u4e86<\/p>\n<p>\u9519\u8bef\u793a\u4f8b\uff1a<\/p>\n<pre><code class=\"hljs sql\">\/\/ Fatal error: <span class=\"hljs-keyword\">Call<\/span> <span class=\"hljs-keyword\">to<\/span> undefined <span class=\"hljs-keyword\">function<\/span> hpinfo() <span class=\"hljs-keyword\">in<\/span> \/tmp\/php\/<span class=\"hljs-keyword\">index<\/span>.php <span class=\"hljs-keyword\">on<\/span> line <span class=\"hljs-number\">5<\/span>\r\nhpinfo();  \/\/E_ERROR<\/code><\/pre>\n<p>\u6ce8\u610f\uff0c\u5982\u679c\u6709\u672a\u88ab\u6355\u83b7\u7684\u5f02\u5e38\uff0c\u4e5f\u662f\u4f1a\u89e6\u53d1\u8fd9\u4e2a\u7ea7\u522b\u7684\u3002<\/p>\n<pre><code class=\"hljs coffeescript\"><span class=\"hljs-regexp\">\/\/<\/span> Fatal error: Uncaught exception <span class=\"hljs-string\">'Exception'<\/span> with message <span class=\"hljs-string\">'test exception'<\/span> <span class=\"hljs-keyword\">in<\/span> \/tmp\/php\/index.php:<span class=\"hljs-number\">5<\/span> Stack trace: <span class=\"hljs-comment\">#0 {main} thrown in \/tmp\/php\/index.php on line 5<\/span>\r\n<span class=\"hljs-keyword\">throw<\/span> <span class=\"hljs-keyword\">new<\/span> \\Exception(<span class=\"hljs-string\">\"test exception\"<\/span>);<\/code><\/pre>\n<h2 id=\"e_warning\">E_WARNING<\/h2>\n<p>\u8fd9\u79cd\u9519\u8bef\u53ea\u662f\u8b66\u544a\uff0c\u4e0d\u4f1a\u7ec8\u6b62\u811a\u672c\uff0c\u7a0b\u5e8f\u8fd8\u4f1a\u7ee7\u7eed\u8fdb\u884c\uff0c\u663e\u793a\u7684\u9519\u8bef\u4fe1\u606f\u662fWarning\u3002\u6bd4\u5982include\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684\u6587\u4ef6\u3002<\/p>\n<pre><code class=\"hljs ruby\">\/<span class=\"hljs-regexp\">\/Warning: include(a.php): failed to open stream: No such file or directory in \/tmp<\/span><span class=\"hljs-regexp\">\/php\/index<\/span>.php on line <span class=\"hljs-number\">7<\/span>\r\n\/<span class=\"hljs-regexp\">\/Warning: include(): Failed opening 'a.php' for inclusion (include_path='.:\/usr<\/span><span class=\"hljs-regexp\">\/share\/pear<\/span><span class=\"hljs-symbol\">:\/usr\/share\/php<span class=\"hljs-string\">') in \/tmp\/php\/index.php on line 7\r\ninclude(\"a.php\"); \/\/E_WARNING<\/span><\/span><\/code><\/pre>\n<h2 id=\"e_notice\">E_NOTICE<\/h2>\n<p>\u8fd9\u79cd\u9519\u8bef\u7a0b\u5ea6\u66f4\u4e3a\u8f7b\u5fae\u4e00\u4e9b\uff0c\u63d0\u793a\u4f60\u8fd9\u4e2a\u5730\u65b9\u4e0d\u5e94\u8be5\u8fd9\u4e48\u5199\u3002\u8fd9\u4e2a\u4e5f\u662f\u8fd0\u884c\u65f6\u9519\u8bef\uff0c\u8fd9\u4e2a\u9519\u8bef\u7684\u4ee3\u7801\u53ef\u80fd\u5728\u5176\u4ed6\u5730\u65b9\u6ca1\u6709\u95ee\u9898\uff0c\u53ea\u662f\u5728\u5f53\u524d\u4e0a\u4e0b\u6587\u60c5\u51b5\u4e0b\u51fa\u73b0\u4e86\u95ee\u9898\u3002<\/p>\n<p>\u6bd4\u5982$b\u53d8\u91cf\u4e0d\u5b58\u5728\uff0c\u6211\u4eec\u628a\u5b83\u8d4b\u503c\u7ed9\u53e6\u5916\u4e00\u4e2a\u53d8\u91cf<\/p>\n<pre><code class=\"hljs ruby\">\/<span class=\"hljs-regexp\">\/Notice: Undefined variable: b in \/tmp<\/span><span class=\"hljs-regexp\">\/php\/index<\/span>.php on line <span class=\"hljs-number\">9<\/span>\r\n$a = $b; <span class=\"hljs-regexp\">\/\/<\/span>E_NOTICE<\/code><\/pre>\n<h2 id=\"e_parse\">E_PARSE<\/h2>\n<p>\u8fd9\u4e2a\u9519\u8bef\u662f\u7f16\u8bd1\u65f6\u5019\u53d1\u751f\u7684\uff0c\u5728\u7f16\u8bd1\u671f\u53d1\u73b0\u8bed\u6cd5\u9519\u8bef\uff0c\u4e0d\u80fd\u8fdb\u884c\u8bed\u6cd5\u5206\u6790\u3002<\/p>\n<p>\u6bd4\u5982\u4e0b\u9762\u7684z\u6ca1\u6709\u8bbe\u7f6e\u4e3a\u53d8\u91cf\u3002<\/p>\n<pre><code class=\"hljs lua\">\/\/ Parse <span class=\"hljs-built_in\">error<\/span>: syntax <span class=\"hljs-built_in\">error<\/span>, unexpected <span class=\"hljs-string\">'='<\/span> <span class=\"hljs-keyword\">in<\/span> \/tmp\/php\/index.php on line <span class=\"hljs-number\">20<\/span>\r\nz=<span class=\"hljs-number\">1<\/span>; \/\/ E_PARSE<\/code><\/pre>\n<h2 id=\"e_strict\">E_STRICT<\/h2>\n<p>\u8fd9\u4e2a\u9519\u8bef\u662fPHP5\u4e4b\u540e\u5f15\u5165\u7684\uff0c\u4f60\u7684\u4ee3\u7801\u53ef\u4ee5\u8fd0\u884c\uff0c\u4f46\u662f\u4e0d\u662fPHP\u5efa\u8bae\u7684\u5199\u6cd5\u3002<\/p>\n<p>\u6bd4\u5982\u5728\u51fd\u6570\u5f62\u53c2\u4f20\u9012++\u7b26\u53f7<\/p>\n<pre><code class=\"hljs php\"><span class=\"hljs-comment\">\/\/ Strict Standards: Only variables should be passed by reference in \/tmp\/php\/index.php on line 17<\/span>\r\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">change<\/span> <span class=\"hljs-params\">(&amp;$var)<\/span> <\/span>{\r\n  $var += <span class=\"hljs-number\">10<\/span>;\r\n}\r\n\r\n$var = <span class=\"hljs-number\">1<\/span>;\r\nchange(++$var);\r\n<span class=\"hljs-comment\">\/\/ E_STRICT<\/span><\/code><\/pre>\n<h2 id=\"e_recoverable_error\">E_RECOVERABLE_ERROR<\/h2>\n<p>\u8fd9\u4e2a\u7ea7\u522b\u5176\u5b9e\u662fERROR\u7ea7\u522b\u7684\uff0c\u4f46\u662f\u5b83\u662f\u671f\u671b\u88ab\u6355\u83b7\u7684\uff0c\u5982\u679c\u6ca1\u6709\u88ab\u9519\u8bef\u5904\u7406\u6355\u83b7\uff0c\u8868\u73b0\u548cE_ERROR\u662f\u4e00\u6837\u7684\u3002<\/p>\n<p>\u7ecf\u5e38\u51fa\u73b0\u5728\u5f62\u53c2\u5b9a\u4e49\u4e86\u7c7b\u578b\uff0c\u4f46\u8c03\u7528\u7684\u65f6\u5019\u4f20\u5165\u4e86\u9519\u8bef\u7c7b\u578b\u3002\u5b83\u7684\u9519\u8bef\u63d0\u9192\u4e5f\u6bd4E_ERROR\u7684fatal error\u524d\u9762\u591a\u4e86\u4e00\u4e2aCatachable\u7684\u5b57\u6837\u3002<\/p>\n<pre><code class=\"hljs php\"><span class=\"hljs-comment\">\/\/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<\/span>\r\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">A<\/span> <\/span>{\r\n}\r\n\r\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">B<\/span> <\/span>{\r\n}\r\n\r\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">testCall<\/span><span class=\"hljs-params\">(A $a)<\/span> <\/span>{\r\n}\r\n\r\n$b = <span class=\"hljs-keyword\">new<\/span> B();\r\ntestCall($b);<\/code><\/pre>\n<h2 id=\"e_deprecated\">E_DEPRECATED<\/h2>\n<p>\u8fd9\u4e2a\u9519\u8bef\u8868\u793a\u4f60\u7528\u4e86\u4e00\u4e2a\u65e7\u7248\u672c\u7684\u51fd\u6570\uff0c\u800c\u8fd9\u4e2a\u51fd\u6570\u540e\u671f\u7248\u672c\u53ef\u80fd\u88ab\u7981\u7528\u6216\u8005\u4e0d\u7ef4\u62a4\u4e86\u3002<\/p>\n<p>\u6bd4\u5982curl\u7684CURLOPT_POSTFIELDS\u4f7f\u7528\\@FILENAME\u6765\u4e0a\u4f20\u6587\u4ef6\u7684\u65b9\u6cd5<\/p>\n<pre><code class=\"hljs php\"><span class=\"hljs-comment\">\/\/ 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<\/span>\r\n$ch = curl_init(<span class=\"hljs-string\">\"http:\/\/www.remotesite.com\/upload.php\"<\/span>);\r\ncurl_setopt($ch, CURLOPT_POSTFIELDS, <span class=\"hljs-keyword\">array<\/span>(<span class=\"hljs-string\">'fileupload'<\/span> =&gt; <span class=\"hljs-string\">'@'<\/span>. <span class=\"hljs-string\">\"test\"<\/span>));<\/code><\/pre>\n<h2 id=\"e_core_error-e_core_warning\">E_CORE_ERROR, E_CORE_WARNING<\/h2>\n<p>\u8fd9\u4e24\u4e2a\u9519\u8bef\u662f\u7531PHP\u7684\u5f15\u64ce\u4ea7\u751f\u7684\uff0c\u5728PHP\u521d\u59cb\u5316\u8fc7\u7a0b\u4e2d\u53d1\u751f\u3002<\/p>\n<h2 id=\"e_compile_error-e_compile_warning\">E_COMPILE_ERROR, E_COMPILE_WARNING<\/h2>\n<p>\u8fd9\u4e24\u4e2a\u9519\u8bef\u662f\u7531PHP\u5f15\u64ce\u4ea7\u751f\u7684\uff0c\u5728\u7f16\u8bd1\u8fc7\u7a0b\u4e2d\u53d1\u751f\u3002<\/p>\n<h2 id=\"e_user_error-e_user_warning-e_user_notice-e_user_deprecated\">E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE, E_USER_DEPRECATED,<\/h2>\n<p>\u8fd9\u4e9b\u9519\u8bef\u90fd\u662f\u7528\u6237\u5236\u9020\u7684\uff0c\u4f7f\u7528trigger_error\uff0c\u8fd9\u91cc\u5c31\u76f8\u5f53\u4e8e\u4e00\u4e2a\u53e3\u5b50\u7ed9\u7528\u6237\u89e6\u53d1\u51fa\u5404\u79cd\u9519\u8bef\u7c7b\u578b\u3002\u8fd9\u4e2a\u662f\u4e00\u4e2a\u5f88\u597d\u9003\u907ftry catch\u5f02\u5e38\u7684\u65b9\u5f0f\u3002<\/p>\n<pre><code class=\"hljs cpp\">trigger_error(<span class=\"hljs-string\">\"Cannot divide by zero\"<\/span>, E_USER_ERROR);\r\n<span class=\"hljs-comment\">\/\/ E_USER_ERROR<\/span>\r\n<span class=\"hljs-comment\">\/\/ E_USER_WARING<\/span>\r\n<span class=\"hljs-comment\">\/\/ E_USER_NOTICE<\/span>\r\n<span class=\"hljs-comment\">\/\/ E_USER_DEPRECATED<\/span><\/code><\/pre>\n<h2 id=\"e_all\">E_ALL<\/h2>\n<p>E_STRICT\u51fa\u5916\u7684\u6240\u6709\u9519\u8bef\u548c\u8b66\u544a\u4fe1\u606f\u3002<\/p>\n<h1 id=\"\u9519\u8bef\u63a7\u5236\">\u9519\u8bef\u63a7\u5236<\/h1>\n<p>php\u4e2d\u6709\u5f88\u591a\u914d\u7f6e\u548c\u53c2\u6570\u662f\u53ef\u4ee5\u63a7\u5236\u9519\u8bef\uff0c\u4ee5\u53ca\u9519\u8bef\u7684\u65e5\u5fd7\u663e\u793a\u7684\u3002\u7b2c\u4e00\u6b65\uff0c\u6211\u4eec\u9700\u8981\u4e86\u89e3\u7684\u662fphp\u4e2d\u7684\u6709\u5173\u9519\u8bef\u7684\u914d\u7f6e\u6709\u54ea\u4e9b\uff1f<\/p>\n<p>\u6211\u4eec\u6309\u7167php+php-fpm\u7684\u6a21\u578b\u6765\u8bf4\uff0c\u4f1a\u5f71\u54cdphp\u9519\u8bef\u663e\u793a\u7684\u5176\u5b9e\u662f\u6709\u4e24\u4e2a\u914d\u7f6e\u6587\u4ef6\uff0c\u4e00\u4e2a\u662fphp\u672c\u8eab\u7684\u914d\u7f6e\u6587\u4ef6php.ini\uff0c\u53e6\u5916\u4e00\u4e2a\u662fphp-fpm\u7684\u914d\u7f6e\u6587\u4ef6\uff0cphp-fpm.conf\u3002<\/p>\n<h2 id=\"php.ini\u4e2d\u7684\u914d\u7f6e\">php.ini\u4e2d\u7684\u914d\u7f6e<\/h2>\n<pre><code class=\"hljs delphi\">error_reporting = E_ALL  <span class=\"hljs-comment\">\/\/ \u62a5\u544a\u9519\u8bef\u7ea7\u522b\uff0c\u4ec0\u4e48\u7ea7\u522b\u7684<\/span>\r\nerror_log = \/tmp\/php_errors.log <span class=\"hljs-comment\">\/\/ php\u4e2d\u7684\u9519\u8bef\u663e\u793a\u7684\u65e5\u5fd7\u4f4d\u7f6e<\/span>\r\ndisplay_errors = <span class=\"hljs-keyword\">On<\/span> <span class=\"hljs-comment\">\/\/ \u662f\u5426\u628a\u9519\u8bef\u5c55\u793a\u5728\u8f93\u51fa\u4e0a\uff0c\u8fd9\u4e2a\u8f93\u51fa\u53ef\u80fd\u662f\u9875\u9762\uff0c\u4e5f\u53ef\u80fd\u662fstdout<\/span>\r\ndisplay_startup_errors = <span class=\"hljs-keyword\">On<\/span> <span class=\"hljs-comment\">\/\/ \u662f\u5426\u628a\u542f\u52a8\u8fc7\u7a0b\u7684\u9519\u8bef\u4fe1\u606f\u663e\u793a\u5728\u9875\u9762\u4e0a\uff0c\u8bb0\u5f97\u4e0a\u9762\u8bf4\u7684\u6709\u51e0\u4e2aCore\u7c7b\u578b\u7684\u9519\u8bef\u662f\u542f\u52a8\u65f6\u5019\u53d1\u751f\u7684\uff0c\u8fd9\u4e2a\u5c31\u662f\u63a7\u5236\u8fd9\u4e9b\u9519\u8bef\u662f\u5426\u663e\u793a\u9875\u9762\u7684\u3002<\/span>\r\nlog_errors = <span class=\"hljs-keyword\">On<\/span> <span class=\"hljs-comment\">\/\/ \u662f\u5426\u8981\u8bb0\u5f55\u9519\u8bef\u65e5\u5fd7<\/span>\r\nlog_errors_max_len = <span class=\"hljs-number\">1024<\/span> <span class=\"hljs-comment\">\/\/ \u9519\u8bef\u65e5\u5fd7\u7684\u6700\u5927\u957f\u5ea6<\/span>\r\nignore_repeated_errors = Off <span class=\"hljs-comment\">\/\/ \u662f\u5426\u5ffd\u7565\u91cd\u590d\u7684\u9519\u8bef<\/span>\r\ntrack_errors = Off <span class=\"hljs-comment\">\/\/ \u662f\u5426\u4f7f\u7528\u5168\u5c40\u53d8\u91cf$php_errormsg\u6765\u8bb0\u5f55\u6700\u540e\u4e00\u4e2a\u9519\u8bef<\/span>\r\nxmlrpc_errors = <span class=\"hljs-number\">0<\/span> <span class=\"hljs-comment\">\/\/\u662f\u5426\u4f7f\u7528XML-RPC\u7684\u9519\u8bef\u4fe1\u606f\u683c\u5f0f\u8bb0\u5f55\u9519\u8bef<\/span>\r\nxmlrpc_error_number = <span class=\"hljs-number\">0<\/span> <span class=\"hljs-comment\">\/\/ \u7528\u4f5c XML-RPC faultCode \u5143\u7d20\u7684\u503c\u3002<\/span>\r\nhtml_errors = <span class=\"hljs-keyword\">On<\/span>  <span class=\"hljs-comment\">\/\/ \u662f\u5426\u628a\u8f93\u51fa\u4e2d\u7684\u51fd\u6570\u7b49\u4fe1\u606f\u53d8\u4e3aHTML\u94fe\u63a5<\/span>\r\ndocref_root = http:<span class=\"hljs-comment\">\/\/manual\/en\/ \/\/ \u5982\u679chtml_errors\u5f00\u542f\u4e86\uff0c\u8fd9\u4e2a\u94fe\u63a5\u7684\u6839\u8def\u5f84\u662f\u4ec0\u4e48<\/span>\r\nfastcgi.logging = <span class=\"hljs-number\">0<\/span> <span class=\"hljs-comment\">\/\/ \u662f\u5426\u628aphp\u9519\u8bef\u629b\u51fa\u5230fastcgi\u4e2d<\/span><\/code><\/pre>\n<p>\u6211\u4eec\u7ecf\u5e38\u4f1a\u88ab\u95ee\u5230\uff0cerror_reporting\u548cdisplay_errors\u6709\u4ec0\u4e48\u533a\u522b\u5462\uff1f\u8fd9\u4e24\u4e2a\u51fd\u6570\u662f\u5b8c\u5168\u4e0d\u4e00\u6837\u7684\u3002<br \/>\nPHP\u9ed8\u8ba4\u662f\u4f1a\u5728\u65e5\u5fd7\u548c\u6807\u51c6\u8f93\u51fa\uff08\u5982\u679c\u662ffpm\u6a21\u5f0f\u6807\u51c6\u8f93\u51fa\u5c31\u662f\u9875\u9762\uff09<br \/>\nerror_reporting\u7684\u53c2\u6570\u662f\u9519\u8bef\u7ea7\u522b\u3002\u8868\u793a\u4ec0\u4e48\u6837\u5b50\u7684\u7ea7\u522b\u624d\u5e94\u8be5\u89e6\u53d1\u9519\u8bef\u3002\u5982\u679c\u6211\u4eec\u544a\u8bc9PHP\uff0c\u6240\u6709\u9519\u8bef\u7ea7\u522b\u90fd\u4e0d\u9700\u8981\u89e6\u53d1\u9519\u8bef\uff0c\u90a3\u4e48\uff0c\u4e0d\u7ba1\u662f\u65e5\u5fd7\uff0c\u8fd8\u662f\u9875\u9762\uff0c\u90fd\u4e0d\u4f1a\u663e\u793a\u8fd9\u4e2a\u9519\u8bef\uff0c\u5c31\u76f8\u5f53\u4e8e\u4ec0\u4e48\u90fd\u6ca1\u6709\u53d1\u751f\u3002<br \/>\ndisplay_errors\u662f\u63a7\u5236\u662f\u5426\u8981\u5728\u6807\u51c6\u8f93\u51fa\u5c55\u793a\u9519\u8bef\u4fe1\u606f<br \/>\nlog_errors\u5219\u662f\u63a7\u5236\u662f\u5426\u8981\u5728\u65e5\u5fd7\u4e2d\u8bb0\u5f55\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n<p>error_log\u662f\u663e\u793a\u9519\u8bef\u65e5\u5fd7\u7684\u4f4d\u7f6e\uff0c\u8fd9\u4e2a\u5728php-fpm\u4e2d\u5f80\u5f80\u4f1a\u88ab\u91cd\u5199\uff0c\u4e8e\u662f\u5f80\u5f80\u4f1a\u53d1\u73b0\u7684\u662fcli\u548cfpm\u7684\u9519\u8bef\u65e5\u5fd7\u7adf\u7136\u4e0d\u662f\u5728\u540c\u4e00\u4e2a\u6587\u4ef6\u4e2d\u3002<\/p>\n<p>ignore_repeated_errors\u8fd9\u4e2a\u6807\u8bb0\u63a7\u5236\u7684\u662f\u5982\u679c\u6709\u91cd\u590d\u7684\u65e5\u5fd7\uff0c\u90a3\u4e48\u5c31\u53ea\u4f1a\u8bb0\u5f55\u4e00\u6761\uff0c\u6bd4\u5982\u4e0b\u9762\u7684\u7a0b\u5e8f\uff1a<\/p>\n<pre><code class=\"hljs bash\">error_reporting(E_ALL);\r\nini_<span class=\"hljs-built_in\">set<\/span>(<span class=\"hljs-string\">'ignore_repeated_errors'<\/span>, 1);\r\nini_<span class=\"hljs-built_in\">set<\/span>(<span class=\"hljs-string\">'ignore_repeated_source'<\/span>, 1);\r\n\r\n<span class=\"hljs-variable\">$a<\/span> = <span class=\"hljs-variable\">$c<\/span>; <span class=\"hljs-variable\">$a<\/span> = <span class=\"hljs-variable\">$c<\/span>; \/\/E_NOTICE\r\n\/\/Notice: Undefined variable: c <span class=\"hljs-keyword\">in<\/span> \/tmp\/php\/index.php on line 20<\/code><\/pre>\n<p>\u672c\u6765\u4f1a\u51fa\u73b0\u4e24\u6b21NOTICE\u7684\uff0c\u4f46\u662f\u73b0\u5728\uff0c\u53ea\u4f1a\u51fa\u73b0\u4e00\u6b21\u4e86&#8230;<\/p>\n<p>track_errors\u5f00\u542f\u4f1a\u628a\u6700\u540e\u4e00\u4e2a\u9519\u8bef\u4fe1\u606f\u5b58\u50a8\u5230\u53d8\u91cf\u91cc\u9762\u53bb\uff0c\u8fd9\u4e2a\u53ef\u80fd\u5728\u5bf9\u8bb0\u65e5\u5fd7\u7684\u65f6\u5019\u4f1a\u6709\u4e00\u4e9b\u7528\u5904\u5427\u3002\u4e0d\u8fc7\u6211\u89c9\u5f97\u771f\u662f\u6ca1\u5565\u7528&#8230;<\/p>\n<p>html_errors \u548c docref_root \u4e24\u4e2a\u662f\u4e2a\u633a\u6709\u4eba\u6027\u5316\u7684\u914d\u7f6e\uff0c\u914d\u7f6e\u4e86\u8fd9\u4e24\u4e2a\u53c2\u6570\u4ee5\u540e\uff0c\u6211\u4eec\u8fd4\u56de\u7684\u9519\u8bef\u4fe1\u606f\u4e2d\u5982\u679c\u6709\u4e00\u4e9b\u5728\u6587\u6863\u4e2d\u6709\u7684\u4fe1\u606f\uff0c\u5c31\u4f1a\u53d8\u6210\u94fe\u63a5\u5f62\u5f0f\u3002<\/p>\n<pre><code class=\"hljs lisp\">error_reporting(<span class=\"hljs-name\">E_ALL<\/span>)<span class=\"hljs-comment\">;<\/span>\r\nini_set('html_errors', <span class=\"hljs-number\">1<\/span>)<span class=\"hljs-comment\">;<\/span>\r\nini_set('docref_root', <span class=\"hljs-string\">\"https:\/\/secure.php.net\/manual\/zh\/\"<\/span>)<span class=\"hljs-comment\">;<\/span>\r\n\r\ninclude(<span class=\"hljs-string\">\"a2.php\"<\/span>)<span class=\"hljs-comment\">; \/\/E_WARNING<\/span><\/code><\/pre>\n<p>\u9875\u9762\u663e\u793a\uff1a<img decoding=\"async\" src=\"http:\/\/i12.tietuku.cn\/9a3b1d3f31c10e40.png\" alt=\"WARNING\u9875\u9762\" \/><\/p>\n<p>\u80fd\u8ba9\u4f60\u5feb\u901f\u5b9a\u4f4d\u5230\u6211\u4eec\u51fa\u73b0\u9519\u8bef\u7684\u5730\u65b9\u3002\u662f\u4e0d\u662f\u5f88\u4eba\u6027\uff5e<\/p>\n<h2 id=\"php-fpm\u4e2d\u7684\u914d\u7f6e\">php-fpm\u4e2d\u7684\u914d\u7f6e<\/h2>\n<pre><code class=\"hljs ini\"><span class=\"hljs-attr\">error_log<\/span> = \/var\/log\/php-fpm\/error.log \/\/ php-fpm\u81ea\u8eab\u7684\u65e5\u5fd7\r\n<span class=\"hljs-attr\">log_level<\/span> = notice \/\/ php-fpm\u81ea\u8eab\u7684\u65e5\u5fd7\u8bb0\u5f55\u7ea7\u522b\r\n<span class=\"hljs-attr\">php_flag[display_errors]<\/span> = <span class=\"hljs-literal\">off<\/span> \/\/ \u8986\u76d6php.ini\u4e2d\u7684\u67d0\u4e2a\u914d\u7f6e\u53d8\u91cf\uff0c\u53ef\u88ab\u7a0b\u5e8f\u4e2d\u7684ini_set\u8986\u76d6\r\n<span class=\"hljs-attr\">php_value[display_errors]<\/span> = <span class=\"hljs-literal\">off<\/span> \/\/ \u540cphp_flag\r\n<span class=\"hljs-attr\">php_admin_value[error_log]<\/span> = \/tmp\/www-error.log \/\/ \u8986\u76d6php.ini\u4e2d\u7684\u67d0\u4e2a\u914d\u7f6e\u53d8\u91cf\uff0c\u4e0d\u53ef\u88ab\u7a0b\u5e8f\u4e2d\u7684ini_set\u8986\u76d6\r\n<span class=\"hljs-attr\">php_admin_flag[log_errors]<\/span> = <span class=\"hljs-literal\">on<\/span> \/\/ \u540cphp_admin_value\r\n<span class=\"hljs-attr\">catch_workers_output<\/span> = <span class=\"hljs-literal\">yes<\/span> \/\/ \u662f\u5426\u6293\u53d6fpmworker\u7684\u8f93\u51fa\r\n<span class=\"hljs-attr\">request_slowlog_timeout<\/span> = <span class=\"hljs-number\">0<\/span> \/\/ \u6162\u65e5\u5fd7\u65f6\u957f\r\n<span class=\"hljs-attr\">slowlog<\/span> = \/var\/log\/php-fpm\/www-slow.log \/\/ \u6162\u65e5\u5fd7\u8bb0\u5f55<\/code><\/pre>\n<p>php-fpm\u7684\u914d\u7f6e\u4e2d\u4e5f\u6709\u4e00\u4e2aerror_log\u914d\u7f6e\uff0c\u8fd9\u4e2a\u5f88\u7ecf\u5e38\u4f1a\u548cphp.ini\u4e2d\u7684error_log\u914d\u7f6e\u5f04\u6df7\u3002\u4f46\u4ed6\u4eec\u8bb0\u5f55\u7684\u4e1c\u897f\u662f\u4e0d\u4e00\u6837\u7684\uff0cphp-fpm\u7684error_log\u53ea\u8bb0\u5f55php-fpm\u672c\u8eab\u7684\u65e5\u5fd7\uff0c\u6bd4\u5982fpm\u542f\u52a8\uff0c\u5173\u95ed\u3002<br \/>\n\u800cphp.ini\u4e2d\u7684error_log\u662f\u8bb0\u5f55php\u7a0b\u5e8f\u672c\u8eab\u7684\u9519\u8bef\u65e5\u5fd7\u3002<\/p>\n<p>\u90a3\u4e48\u5728php-fpm\u4e2d\u8981\u8986\u76d6php.ini\u4e2d\u7684error_log\u914d\u7f6e\uff0c\u5c31\u9700\u8981\u4f7f\u7528\u5230\u4e0b\u9762\u51e0\u4e2a\u51fd\u6570\uff1a<\/p>\n<ul>\n<li>php_flag<\/li>\n<li>php_value<\/li>\n<li>php_admin_flag<\/li>\n<li>php_admin_value<\/li>\n<\/ul>\n<p>\u8fd9\u56db\u4e2a\u51fd\u6570admin\u7684\u4e24\u4e2a\u51fd\u6570\u8bf4\u660e\u8fd9\u4e2a\u53d8\u91cf\u8bbe\u7f6e\u5b8c\u4e4b\u540e\uff0c\u4e0d\u80fd\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528ini_set\u628a\u8fd9\u4e2a\u53d8\u91cf\u91cd\u65b0\u8d4b\u503c\u4e86\u3002\u800cphp_flag\/value\u5c31\u4ecd\u7136\u4ee5php\u4ee3\u7801\u4e2d\u7684ini_set\u4e3a\u51c6\u3002<\/p>\n<p>slowlog\u662ffpm\u8bb0\u5f55\u7684\uff0c\u53ef\u4ee5\u4f7f\u7528request_slowlog_timeout\u8bbe\u7f6e\u5224\u65ad\u6162\u65e5\u5fd7\u7684\u65f6\u957f\u3002<\/p>\n<h1 id=\"\u603b\u7ed3\">\u603b\u7ed3<\/h1>\n<p>\u6211\u4eec\u7ecf\u5e38\u5f04\u6df7\u7684\u5c31\u662f\u65e5\u5fd7\u95ee\u9898\uff0c\u4ee5\u53ca\u67d0\u4e9b\u7ea7\u522b\u7684\u65e5\u5fd7\u4e3a\u4f55\u6ca1\u6709\u8bb0\u5f55\u5230\u65e5\u5fd7\u4e2d\u3002\u6700\u4e3b\u8981\u7684\u662f\u8981\u770berror_log\uff0cdisplay_errors, log_errors\u8fd9\u4e09\u4e2a\u914d\u7f6e\uff0c\u53ea\u662f\u5728\u770b\u914d\u7f6e\u7684\u65f6\u5019\uff0c\u6211\u4eec\u8fd8\u8981\u6ce8\u610f\u533a\u5206php.ini\u91cc\u9762\u7684\u914d\u7f6e\u662f\u4ec0\u4e48\uff0cphp-fpm.ini\u91cc\u9762\u7684\u914d\u7f6e\u662f\u4ec0\u4e48\u3002<\/p>\n<p>\u597d\u5427\uff0c\u6211\u89c9\u5f97\u5f04\u61c2\u8fd9\u4e9b\u914d\u7f6e\uff0c\u57fa\u672c\u5c31\u6ca1\u6709php\u65e5\u5fd7\u8bb0\u5f55\u4e0d\u4e86\u7684WTF\u7684\u95ee\u9898\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP\u7684\u9519\u8bef\u673a\u5236\u603b\u7ed3 PHP\u7684\u9519\u8bef\u673a\u5236\u4e5f\u662f\u975e\u5e38\u590d\u6742\u7684\uff0c\u505a\u4e86\u51e0\u5e74php\uff0c\u4e5f\u6ca1\u6709\u4ed4\u7ec6\u603b\u7ed3\u8fc7\uff0c\u73b0\u5728\u5c31\u8865\u4e0a\u8fd9\u4e00\u8bfe\u3002 \u7279\u522b\u8bf4\u660e\uff1a\u6587\u7ae0\u7684PHP\u7248\u672c\u4f7f\u75285.5.32 PHP\u7684&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[54],"tags":[184],"_links":{"self":[{"href":"https:\/\/www.wpadmin.cn\/blog\/wp-json\/wp\/v2\/posts\/3583"}],"collection":[{"href":"https:\/\/www.wpadmin.cn\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wpadmin.cn\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wpadmin.cn\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wpadmin.cn\/blog\/wp-json\/wp\/v2\/comments?post=3583"}],"version-history":[{"count":0,"href":"https:\/\/www.wpadmin.cn\/blog\/wp-json\/wp\/v2\/posts\/3583\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wpadmin.cn\/blog\/wp-json\/wp\/v2\/media?parent=3583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wpadmin.cn\/blog\/wp-json\/wp\/v2\/categories?post=3583"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wpadmin.cn\/blog\/wp-json\/wp\/v2\/tags?post=3583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}