{"id":47270,"date":"2024-12-02T11:09:11","date_gmt":"2024-12-02T03:09:11","guid":{"rendered":"https:\/\/fwq.ai\/blog\/47270\/"},"modified":"2024-12-02T11:09:11","modified_gmt":"2024-12-02T03:09:11","slug":"php-%e5%87%bd%e6%95%b0%e4%b8%ad%e6%9c%89%e5%93%aa%e4%ba%9b%e5%8f%af%e7%94%a8%e7%9a%84%e6%97%a5%e5%bf%97%e8%ae%b0%e5%bd%95%e5%b7%a5%e5%85%b7%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/47270\/","title":{"rendered":"PHP \u51fd\u6570\u4e2d\u6709\u54ea\u4e9b\u53ef\u7528\u7684\u65e5\u5fd7\u8bb0\u5f55\u5de5\u5177\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>PHP \u51fd\u6570\u4e2d\u6709\u54ea\u4e9b\u53ef\u7528\u7684\u65e5\u5fd7\u8bb0\u5f55\u5de5\u5177\uff1f<\/h1>\n<p>\u5728IT\u884c\u4e1a\u8fd9\u4e2a\u53d1\u5c55\u66f4\u65b0\u901f\u5ea6\u5f88\u5feb\u7684\u884c\u4e1a\uff0c\u53ea\u6709\u4e0d\u505c\u6b62\u7684\u5b66\u4e60\uff0c\u624d\u4e0d\u4f1a\u88ab\u884c\u4e1a\u6240\u6dd8\u6c70\u3002\u5982\u679c\u4f60\u662f\u6587\u7ae0\u5b66\u4e60\u8005\uff0c\u90a3\u4e48\u672c\u6587\u300aPHP \u51fd\u6570\u4e2d\u6709\u54ea\u4e9b\u53ef\u7528\u7684\u65e5\u5fd7\u8bb0\u5f55\u5de5\u5177\uff1f\u300b\u5c31\u5f88\u9002\u5408\u4f60\uff01\u672c\u7bc7\u5185\u5bb9\u4e3b\u8981\u5305\u62ec##content_title##\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u52a9\u529b\u5b9e\u6218\u5f00\u53d1\uff01<\/p>\n<p>PHP \u4e2d\u5185\u7f6e\u4e86\u5f3a\u5927\u7684\u65e5\u5fd7\u8bb0\u5f55\u51fd\u6570\uff0c\u5305\u62ec\uff1aerror_log()\uff1a\u8bb0\u5f55\u9519\u8bef\u6216\u8b66\u544a\u6d88\u606f\u3002trigger_error()\uff1a\u89e6\u53d1\u81ea\u5b9a\u4e49\u9519\u8bef\u6216\u8b66\u544a\u3002log()\uff1a\u8bb0\u5f55\u65e5\u5fd7\u6d88\u606f\uff0c\u6307\u5b9a\u8bbe\u65bd\u548c\u4f18\u5148\u7ea7\u3002syslog()\uff1a\u5c06\u6d88\u606f\u8bb0\u5f55\u5230\u7cfb\u7edf\u65e5\u5fd7\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241026\/1729908157671c4dbd994ba.jpg\" class=\"aligncenter\" title=\"PHP \u51fd\u6570\u4e2d\u6709\u54ea\u4e9b\u53ef\u7528\u7684\u65e5\u5fd7\u8bb0\u5f55\u5de5\u5177\uff1f\u63d2\u56fe\" alt=\"PHP \u51fd\u6570\u4e2d\u6709\u54ea\u4e9b\u53ef\u7528\u7684\u65e5\u5fd7\u8bb0\u5f55\u5de5\u5177\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>PHP \u51fd\u6570\u4e2d\u7684\u65e5\u5fd7\u8bb0\u5f55\u5de5\u5177<\/strong><\/p>\n<p><strong>\u7b80\u4ecb<\/strong><\/p>\n<p>\u65e5\u5fd7\u8bb0\u5f55\u5bf9\u4e8e\u8ddf\u8e2a\u548c\u68c0\u6d4b\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u9519\u8bef\u3001\u8b66\u544a\u548c\u4fe1\u606f\u81f3\u5173\u91cd\u8981\u3002PHP \u63d0\u4f9b\u4e86\u591a\u79cd\u5185\u7f6e\u51fd\u6570\uff0c\u4f7f\u5f00\u53d1\u4eba\u5458\u80fd\u591f\u8f7b\u677e\u5730\u8bb0\u5f55\u4e0d\u540c\u7ea7\u522b\u7684\u4fe1\u606f\u3002<\/p>\n<p><strong>\u51fd\u6570<\/strong><\/p>\n<ul>\n<li><strong>error_log()<\/strong>\uff1a\u7528\u4e8e\u8bb0\u5f55\u9519\u8bef\u6216\u8b66\u544a\u6d88\u606f\u3002<\/li>\n<li><strong>trigger_error()<\/strong>\uff1a\u89e6\u53d1\u81ea\u5b9a\u4e49\u9519\u8bef\u6216\u8b66\u544a\u3002<\/li>\n<li><strong>log()<\/strong>\uff1a\u8bb0\u5f55\u65e5\u5fd7\u6d88\u606f\uff0c\u5e76\u5141\u8bb8\u6307\u5b9a\u8bbe\u65bd\u548c\u4f18\u5148\u7ea7\u3002<\/li>\n<li><strong>syslog()<\/strong>\uff1a\u5c06\u6d88\u606f\u8bb0\u5f55\u5230\u7cfb\u7edf\u65e5\u5fd7\u3002<\/li>\n<\/ul>\n<p><strong>\u5b9e\u6218\u6848\u4f8b<\/strong><\/p>\n<p><strong>\u793a\u4f8b 1\uff1a\u4f7f\u7528 error_log() \u8bb0\u5f55\u9519\u8bef\u6d88\u606f<\/strong><\/p>\n<pre>error_log(\"Error encountered: File not found\");<\/pre>\n<p><strong>\u793a\u4f8b 2\uff1a\u4f7f\u7528 trigger_error() \u89e6\u53d1\u81ea\u5b9a\u4e49\u9519\u8bef<\/strong><\/p>\n<pre>trigger_error(\"Custom error: Invalid input\", E_USER_ERROR);<\/pre>\n<p><strong>\u793a\u4f8b 3\uff1a\u4f7f\u7528 log() \u8bb0\u5f55\u65e5\u5fd7\u6d88\u606f<\/strong><\/p>\n<pre>log(LOG_INFO, \"Application started\");\nlog(LOG_WARNING, \"Low memory available\");<\/pre>\n<p><strong>\u793a\u4f8b 4\uff1a\u4f7f\u7528 syslog() \u5c06\u6d88\u606f\u8bb0\u5f55\u5230\u7cfb\u7edf\u65e5\u5fd7<\/strong><\/p>\n<pre>syslog(LOG_ERR, \"Critical error occurred\");<\/pre>\n<p><strong>\u6ce8\u610f\u4e8b\u9879<\/strong><\/p>\n<ul>\n<li><strong>error_log()<\/strong> \u548c <strong>trigger_error()<\/strong> \u4ec5\u8bb0\u5f55\u9519\u8bef\u548c\u8b66\u544a\uff1b\u5bf9\u4e8e\u66f4\u8be6\u7ec6\u7684\u65e5\u5fd7\u8bb0\u5f55\uff0c\u8bf7\u4f7f\u7528 <strong>log()<\/strong> \u548c <strong>syslog()<\/strong>.<\/li>\n<li><strong>log()<\/strong> \u51fd\u6570\u9700\u8981 PHP \u7684 syslog \u6269\u5c55\u3002<\/li>\n<li>\u7cfb\u7edf\u65e5\u5fd7\u7684\u4f4d\u7f6e\u548c\u683c\u5f0f\u53d6\u51b3\u4e8e\u64cd\u4f5c\u7cfb\u7edf\u7684\u914d\u7f6e\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u7684\u5168\u90e8\u5185\u5bb9\u4e86\uff0c\u662f\u5426\u6709\u987a\u5229\u5e2e\u52a9\u4f60\u89e3\u51b3\u95ee\u9898\uff1f\u82e5\u662f\u80fd\u7ed9\u4f60\u5e26\u6765\u5b66\u4e60\u4e0a\u7684\u5e2e\u52a9\uff0c\u8bf7\u5927\u5bb6\u591a\u591a\u652f\u6301\u7c73\u4e91\uff01\u66f4\u591a\u5173\u4e8e\u6587\u7ae0\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u4e5f\u53ef\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP \u51fd\u6570\u4e2d\u6709\u54ea\u4e9b\u53ef\u7528\u7684\u65e5\u5fd7\u8bb0\u5f55\u5de5\u5177\uff1f \u5728IT\u884c\u4e1a\u8fd9\u4e2a\u53d1\u5c55\u66f4\u65b0\u901f\u5ea6\u5f88\u5feb\u7684\u884c\u4e1a\uff0c\u53ea\u6709\u4e0d\u505c\u6b62\u7684\u5b66\u4e60\uff0c\u624d\u4e0d\u4f1a\u88ab\u884c\u4e1a\u6240\u6dd8\u6c70\u3002\u5982\u679c\u4f60\u662f\u6587\u7ae0\u5b66\u4e60\u8005\uff0c\u90a3\u4e48\u672c\u6587\u300aPHP \u51fd\u6570\u4e2d\u6709\u54ea\u4e9b\u53ef\u7528\u7684\u65e5\u5fd7\u8bb0\u5f55\u5de5\u5177\uff1f\u300b\u5c31\u5f88\u9002\u5408\u4f60\uff01\u672c\u7bc7\u5185\u5bb9\u4e3b\u8981\u5305\u62ec##content_title##\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u52a9\u529b\u5b9e\u6218\u5f00\u53d1\uff01 PHP \u4e2d\u5185\u7f6e\u4e86\u5f3a\u5927\u7684\u65e5\u5fd7\u8bb0\u5f55\u51fd\u6570\uff0c\u5305\u62ec\uff1aerror_log()\uff1a\u8bb0\u5f55\u9519\u8bef\u6216\u8b66\u544a\u6d88\u606f\u3002trigger_error()\uff1a\u89e6\u53d1\u81ea\u5b9a\u4e49\u9519\u8bef\u6216\u8b66\u544a\u3002log()\uff1a\u8bb0\u5f55\u65e5\u5fd7\u6d88\u606f\uff0c\u6307\u5b9a\u8bbe\u65bd\u548c\u4f18\u5148\u7ea7\u3002syslog()\uff1a\u5c06\u6d88\u606f\u8bb0\u5f55\u5230\u7cfb\u7edf\u65e5\u5fd7\u3002 PHP \u51fd\u6570\u4e2d\u7684\u65e5\u5fd7\u8bb0\u5f55\u5de5\u5177 \u7b80\u4ecb \u65e5\u5fd7\u8bb0\u5f55\u5bf9\u4e8e\u8ddf\u8e2a\u548c\u68c0\u6d4b\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u9519\u8bef\u3001\u8b66\u544a\u548c\u4fe1\u606f\u81f3\u5173\u91cd\u8981\u3002PHP \u63d0\u4f9b\u4e86\u591a\u79cd\u5185\u7f6e\u51fd\u6570\uff0c\u4f7f\u5f00\u53d1\u4eba\u5458\u80fd\u591f\u8f7b\u677e\u5730\u8bb0\u5f55\u4e0d\u540c\u7ea7\u522b\u7684\u4fe1\u606f\u3002 \u51fd\u6570 error_log()\uff1a\u7528\u4e8e\u8bb0\u5f55\u9519\u8bef\u6216\u8b66\u544a\u6d88\u606f\u3002 trigger_error()\uff1a\u89e6\u53d1\u81ea\u5b9a\u4e49\u9519\u8bef\u6216\u8b66\u544a\u3002 log()\uff1a\u8bb0\u5f55\u65e5\u5fd7\u6d88\u606f\uff0c\u5e76\u5141\u8bb8\u6307\u5b9a\u8bbe\u65bd\u548c\u4f18\u5148\u7ea7\u3002 syslog()\uff1a\u5c06\u6d88\u606f\u8bb0\u5f55\u5230\u7cfb\u7edf\u65e5\u5fd7\u3002 \u5b9e\u6218\u6848\u4f8b \u793a\u4f8b 1\uff1a\u4f7f\u7528 error_log() \u8bb0\u5f55\u9519\u8bef\u6d88\u606f error_log(&#8220;Error encountered: File not found&#8221;); \u793a\u4f8b 2\uff1a\u4f7f\u7528 trigger_error() \u89e6\u53d1\u81ea\u5b9a\u4e49\u9519\u8bef trigger_error(&#8220;Custom error: Invalid input&#8221;, E_USER_ERROR); \u793a\u4f8b 3\uff1a\u4f7f\u7528 log() \u8bb0\u5f55\u65e5\u5fd7\u6d88\u606f log(LOG_INFO, &#8220;Application started&#8221;); log(LOG_WARNING, &#8220;Low memory available&#8221;); \u793a\u4f8b 4\uff1a\u4f7f\u7528 syslog() \u5c06\u6d88\u606f\u8bb0\u5f55\u5230\u7cfb\u7edf\u65e5\u5fd7 syslog(LOG_ERR, &#8220;Critical error occurred&#8221;); \u6ce8\u610f\u4e8b\u9879 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-47270","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=47270"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47270\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=47270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=47270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=47270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}