{"id":191887,"date":"2020-06-01T08:29:18","date_gmt":"2020-06-01T00:29:18","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=191887"},"modified":"2020-05-20T09:29:38","modified_gmt":"2020-05-20T01:29:38","slug":"php-error","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/php-error.html","title":{"rendered":"PHP\u5173\u95ed\u8c03\u8bd5\u6a21\u5f0f\uff0c\u5c4f\u853d\u9519\u8bef"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | \u5728\u7f16\u5199 PHP \u4ee3\u7801\u7684\u65f6\u5019\u96be\u514d\u4f1a\u51fa\u73b0\u9519\u8bef\uff0c\u5f53\u5f88\u591a\u9519\u8bef\u4fe1\u606f\u5806\u79ef\u5230\u4e00\u8d77\u7684\u65f6\u5019\uff0c\u53ef\u80fd\u4f1a\u4f7f\u6211\u4eec\u611f\u5230\u53cd\u611f\uff0c\u800c\u4e14\u9519\u8bef\u4fe1\u606f\u8fd8\u4f1a\u5f71\u54cd\u7528\u6237\u4f53\u9a8c\u3002\u6700\u91cd\u8981\u7684\u662f\uff0c\u5982\u679c\u8fd9\u4e9b\u9519\u8bef\u88ab\u6709\u5fc3\u4eba\u58eb\u770b\u5230\u7684\u8bdd\uff0c\u53ef\u80fd\u5bf9\u6574\u4e2a\u7a0b\u5e8f\u5e26\u6765\u5a01\u80c1\uff0c\u90a3\u4e48\u6211\u4eec\u5e94\u8be5\u5982\u4f55\u5c4f\u853d PHP \u4e2d\u7684\u9519\u8bef\u5462\uff1f<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n PHP \u4e2d\u5c4f\u853d\u9519\u8bef\u7684\u65b9\u6cd5\u67093\u4e2d\uff0c\u4e0b\u9762\u5c31\u6765\u5206\u522b\u4ecb\u7ecd\u4e00\u4e0b\u3002<\/p>\n \u4f7f\u7528\u9519\u8bef\u63a7\u5236\u8fd0\u7b97\u7b26\uff1a@<\/strong><\/span><\/div>\n PHP \u652f\u6301\u4f7f\u7528\u9519\u8bef\u63a7\u5236\u8fd0\u7b97\u7b26@\u3002\u5c06\u5176\u653e\u7f6e\u5728\u4e00\u4e2a PHP \u8868\u8fbe\u5f0f\u4e4b\u524d\uff0c\u8be5\u8868\u8fbe\u5f0f\u53ef\u80fd\u4ea7\u751f\u7684\u4efb\u4f55\u9519\u8bef\u4fe1\u606f\u90fd\u5c06\u88ab\u5ffd\u7565\u6389\u3002<\/p>\n \u5982\u679c\u7528 set_error_handler() \u8bbe\u5b9a\u4e86\u81ea\u5b9a\u4e49\u7684\u9519\u8bef\u5904\u7406\u51fd\u6570\uff0c\u8fd9\u4e2a\u9519\u8bef\u5904\u7406\u51fd\u6570\u4ecd\u7136\u4f1a\u88ab\u8c03\u7528\uff0c\u800c\u5982\u679c\u5728\u51fa\u9519\u8bed\u53e5\u524d\u4f7f\u7528\u4e86@\u7684\u8bdd\uff0c\u9519\u8bef\u5904\u7406\u51fd\u6570\u5c06\u8fd4\u56de 0\u3002<\/p>\n \u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c@\u8fd0\u7b97\u7b26\u53ea\u5bf9\u8868\u8fbe\u5f0f\u6709\u6548\u3002\u7b80\u5355\u6765\u8bf4\u5c31\u662f\uff0c\u5982\u679c\u80fd\u4ece\u67d0\u5904\u5f97\u5230\u503c\uff0c\u5c31\u80fd\u5728\u5b83\u524d\u9762\u52a0\u4e0a @ \u8fd0\u7b97\u7b26\u3002\u4f8b\u5982\u53ef\u4ee5\u5728\u53d8\u91cf\u3001\u51fd\u6570\u3001include \u8c03\u7528\u3001\u5e38\u91cf\u7b49\u7b49\u4e4b\u524d\u4f7f\u7528 @ \u8fd0\u7b97\u7b26\uff0c\u4f46\u4e0d\u80fd\u628a\u5b83\u653e\u5728\u51fd\u6570\u6216\u7c7b\u7684\u5b9a\u4e49\u4e4b\u524d\uff0c\u4e5f\u4e0d\u80fd\u7528\u4e8e\u6761\u4ef6\u7ed3\u6784\u4f8b\u5982 if \u548c foreach \u7b49\u8bed\u53e5\u524d\u3002<\/p>\n @\u8fd0\u7b97\u7b26\u5bf9\u4e8e\u53ef\u4ee5\u5bfc\u81f4\u7a0b\u5e8f\u7ec8\u6b62\u7684\u4e25\u91cd\u9519\u8bef\u4e5f\u662f\u6709\u6548\u7684\uff0c\u8fd9\u610f\u5473\u7740\u5982\u679c\u5728\u67d0\u4e2a\u4e0d\u5b58\u5728\u6216\u8005\u6572\u9519\u4e86\u5b57\u6bcd\u7684\u51fd\u6570\u8c03\u7528\u524d\u7528\u4e86@\u6765\u6291\u5236\u9519\u8bef\u4fe1\u606f\uff0c\u90a3\u4e48\u7a0b\u5e8f\u5c06\u6ca1\u6709\u4efb\u4f55\u63d0\u793a\u7684\u6b7b\u5728\u90a3\u91cc\u3002<\/p>\n \u3010\u793a\u4f8b\u3011\u4f7f\u7528 @ \u9519\u8bef\u63a7\u5236\u8fd0\u7b97\u7b26\u5c4f\u853d\u4ee3\u7801\u4e2d\u7684\u9519\u8bef\u3002<\/p>\n <?php\r\n $link = @mysqli_connect(\"127.0.0.1\", \"my_user\", \"my_password\", \"my_db\") or die('\u6570\u636e\u5e93\u8fde\u63a5\u5931\u8d25\uff01');\r\n?><\/pre>\n |