{"id":47062,"date":"2024-12-02T11:48:55","date_gmt":"2024-12-02T03:48:55","guid":{"rendered":"https:\/\/fwq.ai\/blog\/47062\/"},"modified":"2024-12-02T11:48:55","modified_gmt":"2024-12-02T03:48:55","slug":"php-%e5%87%bd%e6%95%b0%e6%8c%89%e5%85%bc%e5%ae%b9%e6%80%a7%e5%a6%82%e4%bd%95%e5%88%86%e7%b1%bb%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/47062\/","title":{"rendered":"PHP \u51fd\u6570\u6309\u517c\u5bb9\u6027\u5982\u4f55\u5206\u7c7b\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>PHP \u51fd\u6570\u6309\u517c\u5bb9\u6027\u5982\u4f55\u5206\u7c7b\uff1f<\/h1>\n<p>\u6587\u7ae0\u5c0f\u767d\u4e00\u679a\uff0c\u6b63\u5728\u4e0d\u65ad\u5b66\u4e60\u79ef\u7d2f\u77e5\u8bc6\uff0c\u73b0\u5c06\u5b66\u4e60\u5230\u7684\u77e5\u8bc6\u8bb0\u5f55\u4e00\u4e0b\uff0c\u4e5f\u662f\u5c06\u6211\u7684\u6240\u5f97\u5206\u4eab\u7ed9\u5927\u5bb6\uff01\u800c\u4eca\u5929\u8fd9\u7bc7\u6587\u7ae0\u300aPHP \u51fd\u6570\u6309\u517c\u5bb9\u6027\u5982\u4f55\u5206\u7c7b\uff1f\u300b\u5e26\u5927\u5bb6\u6765\u4e86\u89e3\u4e00\u4e0b##content_title##\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u52a9\u529b\u5b9e\u6218\u5f00\u53d1\uff01<\/p>\n<p><\/p>\n<p>PHP \u51fd\u6570\u6839\u636e\u517c\u5bb9\u6027\u53ef\u5206\u4e3a\u6838\u5fc3\u51fd\u6570\u3001\u6269\u5c55\u51fd\u6570\u548c\u7528\u6237\u81ea\u5b9a\u4e49\u51fd\u6570\u3002\u6838\u5fc3\u51fd\u6570\u5728\u6240\u6709 PHP \u7248\u672c\u4e2d\u5747\u53ef\u7528\uff0c\u6269\u5c55\u51fd\u6570\u4ec5\u5728\u542f\u7528\u76f8\u5e94\u6269\u5c55\u65f6\u53ef\u7528\uff0c\u7528\u6237\u81ea\u5b9a\u4e49\u51fd\u6570\u53ea\u5728\u5b83\u4eec\u7684\u811a\u672c\u4e2d\u53ef\u7528\u3002PHP \u51fd\u6570\u8fd8\u6839\u636e\u6dfb\u52a0\u7684 PHP \u7248\u672c\u5206\u7c7b\uff0c\u5f03\u7528\u51fd\u6570\u5c06\u6765\u4f1a\u88ab\u5220\u9664\uff0c\u5efa\u8bae\u4f7f\u7528\u66ff\u4ee3\u65b9\u6cd5\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241025\/1729863337671b9ea94ab67.jpg\" class=\"aligncenter\" title=\"PHP \u51fd\u6570\u6309\u517c\u5bb9\u6027\u5982\u4f55\u5206\u7c7b\uff1f\u63d2\u56fe\" alt=\"PHP \u51fd\u6570\u6309\u517c\u5bb9\u6027\u5982\u4f55\u5206\u7c7b\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>PHP \u51fd\u6570\u6309\u517c\u5bb9\u6027\u7684\u5206\u7c7b<\/strong><\/p>\n<p>PHP \u51fd\u6570\u6839\u636e\u5176\u517c\u5bb9\u6027\u53ef\u5206\u4e3a\u4ee5\u4e0b\u7c7b\u522b\uff1a<\/p>\n<p><strong>\u6838\u5fc3\u51fd\u6570\uff1a<\/strong><\/p>\n<ul>\n<li>\u5b9a\u4e49\u5728 PHP \u6838\u5fc3\u4e2d\u7684\u51fd\u6570<\/li>\n<li>\u5728\u6240\u6709 PHP \u7248\u672c\u4e2d\u90fd\u53ef\u7528<\/li>\n<li>\u4f8b\u5982\uff1a<code>echo()<\/code>\u3001<code>array()<\/code><\/li>\n<\/ul>\n<p><strong>\u6269\u5c55\u51fd\u6570\uff1a<\/strong><\/p>\n<ul>\n<li>\u5b9a\u4e49\u5728 PHP \u6269\u5c55\u4e2d\u7684\u51fd\u6570<\/li>\n<li>\u4ec5\u5728\u542f\u7528\u4e86\u8fd9\u4e9b\u6269\u5c55\u65f6\u53ef\u7528<\/li>\n<li>\u4f8b\u5982\uff1a<code>mysqli_connect()<\/code>\uff08MySQLi \u6269\u5c55\uff09<\/li>\n<\/ul>\n<p><strong>\u7528\u6237\u81ea\u5b9a\u4e49\u51fd\u6570\uff1a<\/strong><\/p>\n<ul>\n<li>\u7531\u7528\u6237\u5b9a\u4e49\u7684\u51fd\u6570<\/li>\n<li>\u53ea\u5728\u5b9a\u4e49\u5b83\u4eec\u7684\u811a\u672c\u4e2d\u53ef\u7528<\/li>\n<\/ul>\n<p><strong>\u517c\u5bb9\u6027\u7248\u672c\uff1a<\/strong><\/p>\n<p>PHP \u51fd\u6570\u8fd8\u6839\u636e\u5b83\u4eec\u6dfb\u52a0\u7684 PHP \u7248\u672c\u8fdb\u884c\u5206\u7c7b\uff1a<\/p>\n<p><strong>\u5f03\u7528\u51fd\u6570\uff1a<\/strong><\/p>\n<ul>\n<li>\u5df2\u6807\u8bb0\u4e3a\u5728\u672a\u6765 PHP \u7248\u672c\u4e2d\u5f03\u7528\u7684\u51fd\u6570<\/li>\n<li>\u5efa\u8bae\u4f7f\u7528\u66ff\u4ee3\u65b9\u6cd5<\/li>\n<li>\u4f8b\u5982\uff1a<code>mysql_connect()<\/code>\uff08\u5df2\u88ab <code>mysqli_connect()<\/code> \u66ff\u4ee3\uff09<\/li>\n<\/ul>\n<p><strong>\u5b9e\u6218\u6848\u4f8b\uff1a<\/strong><\/p>\n<p>\u8003\u8651\u4ee5\u4e0b\u4ee3\u7801\u7247\u6bb5\uff0c\u5b83\u4f7f\u7528 <code>mysqli_connect()<\/code> \u51fd\u6570\uff1a<\/p>\n<pre>&lt;?php\n\/\/ \u521b\u5efa\u8fde\u63a5\n$mysqli = mysqli_connect(\"localhost\", \"root\", \"password\", \"database\");\n\n\/\/ \u68c0\u67e5\u8fde\u63a5\nif ($mysqli === false) {\n    die(\"\u8fde\u63a5\u5931\u8d25\uff1a\" . mysqli_connect_error());\n}\n\n\/\/ \u6267\u884c\u67e5\u8be2\n$result = mysqli_query($mysqli, \"SELECT * FROM users\");\n\n\/\/ \u5904\u7406\u7ed3\u679c\nwhile ($row = mysqli_fetch_assoc($result)) {\n    echo $row['name'] . \"&lt;br&gt;\";\n}\n\n\/\/ \u5173\u95ed\u8fde\u63a5\nmysqli_close($mysqli);\n?&gt;<\/pre>\n<p>\u6b64\u4ee3\u7801\u7247\u6bb5\u4f7f\u7528 <code>mysqli_connect()<\/code> \u6269\u5c55\u51fd\u6570\uff0c\u56e0\u6b64\u5b83\u53ea\u80fd\u5728\u542f\u7528\u4e86 MySQLi \u6269\u5c55\u7684 PHP \u7248\u672c\u4e2d\u4f7f\u7528\u3002<\/p>\n<p>\u672c\u7bc7\u5173\u4e8e\u300aPHP \u51fd\u6570\u6309\u517c\u5bb9\u6027\u5982\u4f55\u5206\u7c7b\uff1f\u300b\u7684\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\u5566\uff0c\u4f46\u662f\u5b66\u65e0\u6b62\u5883\uff0c\u60f3\u8981\u4e86\u89e3\u5b66\u4e60\u66f4\u591a\u5173\u4e8e\u6587\u7ae0\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP \u51fd\u6570\u6309\u517c\u5bb9\u6027\u5982\u4f55\u5206\u7c7b\uff1f \u6587\u7ae0\u5c0f\u767d\u4e00\u679a\uff0c\u6b63\u5728\u4e0d\u65ad\u5b66\u4e60\u79ef\u7d2f\u77e5\u8bc6\uff0c\u73b0\u5c06\u5b66\u4e60\u5230\u7684\u77e5\u8bc6\u8bb0\u5f55\u4e00\u4e0b\uff0c\u4e5f\u662f\u5c06\u6211\u7684\u6240\u5f97\u5206\u4eab\u7ed9\u5927\u5bb6\uff01\u800c\u4eca\u5929\u8fd9\u7bc7\u6587\u7ae0\u300aPHP \u51fd\u6570\u6309\u517c\u5bb9\u6027\u5982\u4f55\u5206\u7c7b\uff1f\u300b\u5e26\u5927\u5bb6\u6765\u4e86\u89e3\u4e00\u4e0b##content_title##\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u52a9\u529b\u5b9e\u6218\u5f00\u53d1\uff01 PHP \u51fd\u6570\u6839\u636e\u517c\u5bb9\u6027\u53ef\u5206\u4e3a\u6838\u5fc3\u51fd\u6570\u3001\u6269\u5c55\u51fd\u6570\u548c\u7528\u6237\u81ea\u5b9a\u4e49\u51fd\u6570\u3002\u6838\u5fc3\u51fd\u6570\u5728\u6240\u6709 PHP \u7248\u672c\u4e2d\u5747\u53ef\u7528\uff0c\u6269\u5c55\u51fd\u6570\u4ec5\u5728\u542f\u7528\u76f8\u5e94\u6269\u5c55\u65f6\u53ef\u7528\uff0c\u7528\u6237\u81ea\u5b9a\u4e49\u51fd\u6570\u53ea\u5728\u5b83\u4eec\u7684\u811a\u672c\u4e2d\u53ef\u7528\u3002PHP \u51fd\u6570\u8fd8\u6839\u636e\u6dfb\u52a0\u7684 PHP \u7248\u672c\u5206\u7c7b\uff0c\u5f03\u7528\u51fd\u6570\u5c06\u6765\u4f1a\u88ab\u5220\u9664\uff0c\u5efa\u8bae\u4f7f\u7528\u66ff\u4ee3\u65b9\u6cd5\u3002 PHP \u51fd\u6570\u6309\u517c\u5bb9\u6027\u7684\u5206\u7c7b PHP \u51fd\u6570\u6839\u636e\u5176\u517c\u5bb9\u6027\u53ef\u5206\u4e3a\u4ee5\u4e0b\u7c7b\u522b\uff1a \u6838\u5fc3\u51fd\u6570\uff1a \u5b9a\u4e49\u5728 PHP \u6838\u5fc3\u4e2d\u7684\u51fd\u6570 \u5728\u6240\u6709 PHP \u7248\u672c\u4e2d\u90fd\u53ef\u7528 \u4f8b\u5982\uff1aecho()\u3001array() \u6269\u5c55\u51fd\u6570\uff1a \u5b9a\u4e49\u5728 PHP \u6269\u5c55\u4e2d\u7684\u51fd\u6570 \u4ec5\u5728\u542f\u7528\u4e86\u8fd9\u4e9b\u6269\u5c55\u65f6\u53ef\u7528 \u4f8b\u5982\uff1amysqli_connect()\uff08MySQLi \u6269\u5c55\uff09 \u7528\u6237\u81ea\u5b9a\u4e49\u51fd\u6570\uff1a \u7531\u7528\u6237\u5b9a\u4e49\u7684\u51fd\u6570 \u53ea\u5728\u5b9a\u4e49\u5b83\u4eec\u7684\u811a\u672c\u4e2d\u53ef\u7528 \u517c\u5bb9\u6027\u7248\u672c\uff1a PHP \u51fd\u6570\u8fd8\u6839\u636e\u5b83\u4eec\u6dfb\u52a0\u7684 PHP \u7248\u672c\u8fdb\u884c\u5206\u7c7b\uff1a \u5f03\u7528\u51fd\u6570\uff1a \u5df2\u6807\u8bb0\u4e3a\u5728\u672a\u6765 PHP \u7248\u672c\u4e2d\u5f03\u7528\u7684\u51fd\u6570 \u5efa\u8bae\u4f7f\u7528\u66ff\u4ee3\u65b9\u6cd5 \u4f8b\u5982\uff1amysql_connect()\uff08\u5df2\u88ab mysqli_connect() \u66ff\u4ee3\uff09 \u5b9e\u6218\u6848\u4f8b\uff1a \u8003\u8651\u4ee5\u4e0b\u4ee3\u7801\u7247\u6bb5\uff0c\u5b83\u4f7f\u7528 mysqli_connect() \u51fd\u6570\uff1a &lt;?php \/\/ \u521b\u5efa\u8fde\u63a5 $mysqli = [&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-47062","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47062","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=47062"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47062\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=47062"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=47062"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=47062"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}