{"id":7771,"date":"2024-11-14T16:50:26","date_gmt":"2024-11-14T08:50:26","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7771\/"},"modified":"2024-11-14T16:50:26","modified_gmt":"2024-11-14T08:50:26","slug":"php-8-0-%e4%b8%ad-%e6%8a%91%e6%ad%a2%e7%ac%a6%e5%a4%b1%e6%95%88%ef%bc%8c%e5%a6%82%e4%bd%95%e5%a4%84%e7%90%86%e8%87%b4%e5%91%bd%e9%94%99%e8%af%af%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7771\/","title":{"rendered":"PHP 8.0 \u4e2d @ \u6291\u6b62\u7b26\u5931\u6548\uff0c\u5982\u4f55\u5904\u7406\u81f4\u547d\u9519\u8bef\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173122770918785.jpg\" class=\"aligncenter\" title=\"PHP 8.0 \u4e2d @ \u6291\u6b62\u7b26\u5931\u6548\uff0c\u5982\u4f55\u5904\u7406\u81f4\u547d\u9519\u8bef\uff1f\u63d2\u56fe\" alt=\"PHP 8.0 \u4e2d @ \u6291\u6b62\u7b26\u5931\u6548\uff0c\u5982\u4f55\u5904\u7406\u81f4\u547d\u9519\u8bef\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u9690\u533f\u9519\u8bef\u4fe1\u606f\u65e0\u6548\uff1f<\/strong><\/p>\n<p>\u4f60\u5728\u4f7f\u7528 if \u8bed\u53e5\u6765\u8fde\u63a5\u6570\u636e\u5e93\uff0c\u5e76\u5728\u8f93\u5165\u9519\u8bef\u767b\u5f55\u4fe1\u606f\u65f6\u5e0c\u671b\u770b\u5230 if \u8bed\u53e5\u4e2d\u7684\u9519\u8bef\u4fe1\u606f\u3002\u7136\u800c\uff0c\u7cfb\u7edf\u5374\u62a5\u544a\u4e86\u4e00\u4e2a\u81f4\u547d\u9519\u8bef\uff0c\u8ba9\u4f60\u6000\u7591\u914d\u7f6e\u6587\u4ef6\u7684\u95ee\u9898\u6216\u5176\u4ed6\u672a\u77e5\u56e0\u7d20\u3002<\/p>\n<p><strong>\u539f\u56e0\u89e3\u60d1\uff1a<\/strong><\/p>\n<p>\u4ece php 8.0 \u7248\u672c\u5f00\u59cb\uff0c@ \u6291\u6b62\u7b26\u4e0d\u518d\u6709\u6548\u6291\u5236\u81f4\u547d\u7ea7\u522b\u7684\u9519\u8bef\u3002\u8fd9\u610f\u5473\u7740\u4e00\u65e6\u53d1\u751f\u81f4\u547d\u9519\u8bef\uff0c\u5373\u4f7f\u4f7f\u7528 @ \u4e5f\u65e0\u6cd5\u963b\u6b62\u5176\u663e\u793a\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p><strong>\u89e3\u51b3\u529e\u6cd5\uff1a<\/strong><\/p>\n<p>\u4e3a\u4e86\u4ec5\u5728\u9519\u8bef\u53d1\u751f\u65f6\u663e\u793a if \u8bed\u53e5\u4e2d\u7684\u9519\u8bef\u4fe1\u606f\uff0c\u4f60\u9700\u8981\u4f7f\u7528 <strong>try-catch<\/strong> \u8bed\u53e5\u3002\u8be5\u8bed\u53e5\u5141\u8bb8\u4f60\u6355\u83b7\u7279\u5b9a\u7c7b\u578b\u7684\u5f02\u5e38\uff08\u4f8b\u5982\u6570\u636e\u5e93\u8fde\u63a5\u9519\u8bef\uff09\uff0c\u5e76\u63d0\u4f9b\u81ea\u5b9a\u4e49\u9519\u8bef\u5904\u7406\u903b\u8f91\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>try {\n    \/\/ \u6570\u636e\u5e93\u8fde\u63a5\u4ee3\u7801\n} catch (PDOException $e) {\n    echo $e-&gt;getMessage(); \/\/ \u663e\u793a\u81ea\u5b9a\u4e49\u9519\u8bef\u4fe1\u606f\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fPHP 8.0 \u4e2d @ \u6291\u6b62\u7b26\u5931\u6548\uff0c\u5982\u4f55\u5904\u7406\u81f4\u547d\u9519\u8bef\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9690\u533f\u9519\u8bef\u4fe1\u606f\u65e0\u6548\uff1f \u4f60\u5728\u4f7f\u7528 if \u8bed\u53e5\u6765\u8fde\u63a5\u6570\u636e\u5e93\uff0c\u5e76\u5728\u8f93\u5165\u9519\u8bef\u767b\u5f55\u4fe1\u606f\u65f6\u5e0c\u671b\u770b\u5230 if \u8bed\u53e5\u4e2d\u7684\u9519\u8bef\u4fe1\u606f\u3002\u7136\u800c\uff0c\u7cfb\u7edf\u5374\u62a5\u544a\u4e86\u4e00\u4e2a\u81f4\u547d\u9519\u8bef\uff0c\u8ba9\u4f60\u6000\u7591\u914d\u7f6e\u6587\u4ef6\u7684\u95ee\u9898\u6216\u5176\u4ed6\u672a\u77e5\u56e0\u7d20\u3002 \u539f\u56e0\u89e3\u60d1\uff1a \u4ece php 8.0 \u7248\u672c\u5f00\u59cb\uff0c@ \u6291\u6b62\u7b26\u4e0d\u518d\u6709\u6548\u6291\u5236\u81f4\u547d\u7ea7\u522b\u7684\u9519\u8bef\u3002\u8fd9\u610f\u5473\u7740\u4e00\u65e6\u53d1\u751f\u81f4\u547d\u9519\u8bef\uff0c\u5373\u4f7f\u4f7f\u7528 @ \u4e5f\u65e0\u6cd5\u963b\u6b62\u5176\u663e\u793a\u3002 \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u89e3\u51b3\u529e\u6cd5\uff1a \u4e3a\u4e86\u4ec5\u5728\u9519\u8bef\u53d1\u751f\u65f6\u663e\u793a if \u8bed\u53e5\u4e2d\u7684\u9519\u8bef\u4fe1\u606f\uff0c\u4f60\u9700\u8981\u4f7f\u7528 try-catch \u8bed\u53e5\u3002\u8be5\u8bed\u53e5\u5141\u8bb8\u4f60\u6355\u83b7\u7279\u5b9a\u7c7b\u578b\u7684\u5f02\u5e38\uff08\u4f8b\u5982\u6570\u636e\u5e93\u8fde\u63a5\u9519\u8bef\uff09\uff0c\u5e76\u63d0\u4f9b\u81ea\u5b9a\u4e49\u9519\u8bef\u5904\u7406\u903b\u8f91\u3002\u4f8b\u5982\uff1a try { \/\/ \u6570\u636e\u5e93\u8fde\u63a5\u4ee3\u7801 } catch (PDOException $e) { echo $e-&gt;getMessage(); \/\/ \u663e\u793a\u81ea\u5b9a\u4e49\u9519\u8bef\u4fe1\u606f } \u767b\u5f55\u540e\u590d\u5236 \u4ee5\u4e0a\u5c31\u662fPHP 8.0 \u4e2d @ \u6291\u6b62\u7b26\u5931\u6548\uff0c\u5982\u4f55\u5904\u7406\u81f4\u547d\u9519\u8bef\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/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-7771","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7771","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=7771"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7771\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7771"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7771"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}