{"id":47475,"date":"2024-12-02T15:48:08","date_gmt":"2024-12-02T07:48:08","guid":{"rendered":"https:\/\/fwq.ai\/blog\/47475\/"},"modified":"2024-12-02T15:48:08","modified_gmt":"2024-12-02T07:48:08","slug":"%e4%bd%bf%e7%94%a8-php-%e5%87%bd%e6%95%b0%e5%bc%95%e7%94%a8%e5%8f%82%e6%95%b0%e5%a4%84%e7%90%86%e5%a4%8d%e6%9d%82%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/47475\/","title":{"rendered":"\u4f7f\u7528 PHP \u51fd\u6570\u5f15\u7528\u53c2\u6570\u5904\u7406\u590d\u6742\u6570\u636e\u7ed3\u6784"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u4f7f\u7528 PHP \u51fd\u6570\u5f15\u7528\u53c2\u6570\u5904\u7406\u590d\u6742\u6570\u636e\u7ed3\u6784<\/h1>\n<p>\u76ee\u524d\u7c73\u4e91\u4e0a\u5df2\u7ecf\u6709\u5f88\u591a\u5173\u4e8e<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u7684\u6587\u7ae0\u4e86\uff0c\u81ea\u5df1\u5728\u521d\u6b21\u9605\u8bfb\u8fd9\u4e9b\u6587\u7ae0\u4e2d\uff0c\u4e5f\u89c1\u8bc6\u5230\u4e86\u5f88\u591a\u5b66\u4e60\u601d\u8def\uff1b\u90a3\u4e48\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u4f7f\u7528 PHP \u51fd\u6570\u5f15\u7528\u53c2\u6570\u5904\u7406\u590d\u6742\u6570\u636e\u7ed3\u6784\u300b<\/span>\uff0c\u4e5f\u5e0c\u671b\u80fd\u5e2e\u52a9\u5230\u5927\u5bb6\uff0c\u5982\u679c\u9605\u8bfb\u5b8c\u540e\u771f\u7684\u5bf9\u4f60\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u6709\u5e2e\u52a9\uff0c\u6b22\u8fce\u52a8\u52a8\u624b\u6307\uff0c\u8bc4\u8bba\u7559\u8a00\u5e76\u5206\u4eab~<\/p>\n<p>PHP \u51fd\u6570\u5f15\u7528\u53c2\u6570\u53ef\u4f18\u5316\u590d\u6742\u6570\u636e\u7ed3\u6784\u5904\u7406\u3002\u6309\u5f15\u7528\u4f20\u9012 (&amp;) \u4f1a\u76f4\u63a5\u64cd\u4f5c\u51fd\u6570\u5916\u53d8\u91cf\uff0c\u5bf9\u4e8e\u6570\u7ec4\u6216\u5bf9\u8c61\u7b49\u7ed3\u6784\uff0c\u53ef\u63d0\u9ad8\u6548\u7387\u3002\u6309\u5f15\u7528\u4f20\u9012\u53c2\u6570\u65f6\uff0c\u4f7f\u7528\u6848\u4f8b\u5305\u62ec\u4fee\u6539\u6570\u7ec4\uff1a\u6309\u5f15\u7528\u4f20\u9012\u6570\u7ec4\u5e76\u904d\u5386\u5d4c\u5957\u6570\u7ec4\u8fdb\u884c\u4fee\u6539\uff0c\u53ef\u76f4\u63a5\u66f4\u65b0\u539f\u59cb\u6570\u636e\u7ed3\u6784\uff0c\u907f\u514d\u521b\u5efa\u526f\u672c\u3002\u4f46\u9700\u8981\u6ce8\u610f\u51fd\u6570\u4fee\u6539\u5f15\u7528\u53c2\u6570\u7684\u610f\u5916\u884c\u4e3a\uff0c\u907f\u514d\u91cd\u65b0\u8d4b\u503c\u548c\u5728\u5d4c\u5957\u51fd\u6570\u4e2d\u4f20\u9012\u5f15\u7528\u53c2\u6570\uff0c\u4ee5\u9632\u6570\u636e\u635f\u574f\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241026\/1729919673671c7ab92dc91.jpg\" class=\"aligncenter\" title=\"\u4f7f\u7528 PHP \u51fd\u6570\u5f15\u7528\u53c2\u6570\u5904\u7406\u590d\u6742\u6570\u636e\u7ed3\u6784\u63d2\u56fe\" alt=\"\u4f7f\u7528 PHP \u51fd\u6570\u5f15\u7528\u53c2\u6570\u5904\u7406\u590d\u6742\u6570\u636e\u7ed3\u6784\u63d2\u56fe\" \/><\/p>\n<p><strong>PHP \u51fd\u6570\u5f15\u7528\u53c2\u6570\u5904\u7406\u590d\u6742\u6570\u636e\u7ed3\u6784<\/strong><\/p>\n<p>\u5728 PHP \u4e2d\uff0c\u51fd\u6570\u53c2\u6570\u53ef\u4ee5\u6309\u503c\u4f20\u9012\u6216\u6309\u5f15\u7528\u4f20\u9012\u3002\u6309\u503c\u4f20\u9012\u4f1a\u521b\u5efa\u4e00\u4e2a\u53c2\u6570\u7684\u526f\u672c\uff0c\u800c\u6309\u5f15\u7528\u4f20\u9012\u4f1a\u76f4\u63a5\u64cd\u4f5c\u51fd\u6570\u5916\u5b9a\u4e49\u7684\u53d8\u91cf\u3002\u5bf9\u4e8e\u590d\u6742\u7684\u6570\u636e\u7ed3\u6784\uff0c\u5982\u6570\u7ec4\u6216\u5bf9\u8c61\uff0c\u6309\u5f15\u7528\u4f20\u9012\u53ef\u4ee5\u63d0\u9ad8\u6548\u7387\u548c\u6613\u7528\u6027\u3002<\/p>\n<p><strong>\u6309\u5f15\u7528\u4f20\u9012<\/strong><\/p>\n<p>\u8981\u6309\u5f15\u7528\u4f20\u9012\u53c2\u6570\uff0c\u5728\u53c2\u6570\u7c7b\u578b\u58f0\u660e\u524d\u6dfb\u52a0\u4e00\u4e2a <code>&amp;<\/code> \u7b26\u53f7\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>function myFunction(&amp;$array) {\n  \/\/ \u4ee3\u7801\u5728\u8fd9\u91cc\n}<\/pre>\n<p><strong>\u4f7f\u7528\u6848\u4f8b\uff1a\u4fee\u6539\u6570\u7ec4<\/strong><\/p>\n<p>\u8003\u8651\u4e00\u4e2a\u5305\u542b\u540d\u79f0\u548c\u5730\u5740\u4fe1\u606f\u7684\u6570\u7ec4\uff1a<\/p>\n<pre>$people = [\n  ['name' =&gt; 'John', 'address' =&gt; '123 Main St'],\n  ['name' =&gt; 'Mary', 'address' =&gt; '456 Elm St'],\n];<\/pre>\n<p>\u6211\u4eec\u5e0c\u671b\u521b\u5efa\u4e00\u4e2a\u51fd\u6570\u6765\u66f4\u65b0\u6bcf\u4e2a\u4eba\u7684\u5730\u5740\u3002\u6309\u503c\u4f20\u9012\u5c06\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u6570\u7ec4\u526f\u672c\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5f88\u4f4e\u6548\u3002\u76f8\u53cd\uff0c\u6211\u4eec\u53ef\u4ee5\u6309\u5f15\u7528\u4f20\u9012\u6570\u7ec4\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>function updateAddresses(&amp;$people) {\n  foreach ($people as &amp;$person) {\n    $person['address'] = 'New Address';\n  }\n}\n\nupdateAddresses($people);\n\nprint_r($people); \/\/ \u8f93\u51fa\u66f4\u65b0\u540e\u7684\u5730\u5740<\/pre>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>&amp;$person<\/code> \u4f1a\u5bf9 <code>$people<\/code> \u6570\u7ec4\u4e2d\u7684\u6bcf\u4e2a\u5d4c\u5957\u6570\u7ec4\u8fdb\u884c\u5f15\u7528\u3002\u5f53\u6211\u4eec\u66f4\u65b0 <code>$person['address']<\/code> \u65f6\uff0c\u5b83\u76f4\u63a5\u66f4\u65b0 <code>$people<\/code> \u6570\u7ec4\u4e2d\u5bf9\u5e94\u5143\u7d20\u7684\u5730\u5740\u3002<\/p>\n<p><strong>\u6309\u5f15\u7528\u4f20\u9012\uff1a\u6ce8\u610f<\/strong><\/p>\n<p>\u867d\u7136\u6309\u5f15\u7528\u4f20\u9012\u5bf9\u4e8e\u4fee\u6539\u590d\u6742\u6570\u636e\u7ed3\u6784\u975e\u5e38\u6709\u7528\uff0c\u4f46\u4e5f\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u4e8b\u9879\uff1a<\/p>\n<ul>\n<li>\u786e\u4fdd\u51fd\u6570\u4e0d\u4f1a\u610f\u5916\u5730\u4fee\u6539\u5f15\u7528\u53c2\u6570\u3002<\/li>\n<li>\u4e0d\u8981\u5728\u51fd\u6570\u5916\u5bf9\u6309\u5f15\u7528\u4f20\u9012\u7684\u53c2\u6570\u91cd\u65b0\u8d4b\u503c\u3002<\/li>\n<li>\u907f\u514d\u5728\u5d4c\u5957\u51fd\u6570\u4e2d\u4f20\u9012\u6309\u5f15\u7528\u4f20\u9012\u7684\u53c2\u6570\u3002<\/li>\n<\/ul>\n<p>\u9075\u5faa\u8fd9\u4e9b\u51c6\u5219\u5c06\u6709\u52a9\u4e8e\u9632\u6b62\u610f\u5916\u884c\u4e3a\u548c\u6570\u636e\u635f\u574f\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u300a\u4f7f\u7528 PHP \u51fd\u6570\u5f15\u7528\u53c2\u6570\u5904\u7406\u590d\u6742\u6570\u636e\u7ed3\u6784\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8e\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 PHP \u51fd\u6570\u5f15\u7528\u53c2\u6570\u5904\u7406\u590d\u6742\u6570\u636e\u7ed3\u6784 \u76ee\u524d\u7c73\u4e91\u4e0a\u5df2\u7ecf\u6709\u5f88\u591a\u5173\u4e8e\u6587\u7ae0\u7684\u6587\u7ae0\u4e86\uff0c\u81ea\u5df1\u5728\u521d\u6b21\u9605\u8bfb\u8fd9\u4e9b\u6587\u7ae0\u4e2d\uff0c\u4e5f\u89c1\u8bc6\u5230\u4e86\u5f88\u591a\u5b66\u4e60\u601d\u8def\uff1b\u90a3\u4e48\u672c\u6587\u300a\u4f7f\u7528 PHP \u51fd\u6570\u5f15\u7528\u53c2\u6570\u5904\u7406\u590d\u6742\u6570\u636e\u7ed3\u6784\u300b\uff0c\u4e5f\u5e0c\u671b\u80fd\u5e2e\u52a9\u5230\u5927\u5bb6\uff0c\u5982\u679c\u9605\u8bfb\u5b8c\u540e\u771f\u7684\u5bf9\u4f60\u5b66\u4e60\u6587\u7ae0\u6709\u5e2e\u52a9\uff0c\u6b22\u8fce\u52a8\u52a8\u624b\u6307\uff0c\u8bc4\u8bba\u7559\u8a00\u5e76\u5206\u4eab~ PHP \u51fd\u6570\u5f15\u7528\u53c2\u6570\u53ef\u4f18\u5316\u590d\u6742\u6570\u636e\u7ed3\u6784\u5904\u7406\u3002\u6309\u5f15\u7528\u4f20\u9012 (&amp;) \u4f1a\u76f4\u63a5\u64cd\u4f5c\u51fd\u6570\u5916\u53d8\u91cf\uff0c\u5bf9\u4e8e\u6570\u7ec4\u6216\u5bf9\u8c61\u7b49\u7ed3\u6784\uff0c\u53ef\u63d0\u9ad8\u6548\u7387\u3002\u6309\u5f15\u7528\u4f20\u9012\u53c2\u6570\u65f6\uff0c\u4f7f\u7528\u6848\u4f8b\u5305\u62ec\u4fee\u6539\u6570\u7ec4\uff1a\u6309\u5f15\u7528\u4f20\u9012\u6570\u7ec4\u5e76\u904d\u5386\u5d4c\u5957\u6570\u7ec4\u8fdb\u884c\u4fee\u6539\uff0c\u53ef\u76f4\u63a5\u66f4\u65b0\u539f\u59cb\u6570\u636e\u7ed3\u6784\uff0c\u907f\u514d\u521b\u5efa\u526f\u672c\u3002\u4f46\u9700\u8981\u6ce8\u610f\u51fd\u6570\u4fee\u6539\u5f15\u7528\u53c2\u6570\u7684\u610f\u5916\u884c\u4e3a\uff0c\u907f\u514d\u91cd\u65b0\u8d4b\u503c\u548c\u5728\u5d4c\u5957\u51fd\u6570\u4e2d\u4f20\u9012\u5f15\u7528\u53c2\u6570\uff0c\u4ee5\u9632\u6570\u636e\u635f\u574f\u3002 PHP \u51fd\u6570\u5f15\u7528\u53c2\u6570\u5904\u7406\u590d\u6742\u6570\u636e\u7ed3\u6784 \u5728 PHP \u4e2d\uff0c\u51fd\u6570\u53c2\u6570\u53ef\u4ee5\u6309\u503c\u4f20\u9012\u6216\u6309\u5f15\u7528\u4f20\u9012\u3002\u6309\u503c\u4f20\u9012\u4f1a\u521b\u5efa\u4e00\u4e2a\u53c2\u6570\u7684\u526f\u672c\uff0c\u800c\u6309\u5f15\u7528\u4f20\u9012\u4f1a\u76f4\u63a5\u64cd\u4f5c\u51fd\u6570\u5916\u5b9a\u4e49\u7684\u53d8\u91cf\u3002\u5bf9\u4e8e\u590d\u6742\u7684\u6570\u636e\u7ed3\u6784\uff0c\u5982\u6570\u7ec4\u6216\u5bf9\u8c61\uff0c\u6309\u5f15\u7528\u4f20\u9012\u53ef\u4ee5\u63d0\u9ad8\u6548\u7387\u548c\u6613\u7528\u6027\u3002 \u6309\u5f15\u7528\u4f20\u9012 \u8981\u6309\u5f15\u7528\u4f20\u9012\u53c2\u6570\uff0c\u5728\u53c2\u6570\u7c7b\u578b\u58f0\u660e\u524d\u6dfb\u52a0\u4e00\u4e2a &amp; \u7b26\u53f7\u3002\u4f8b\u5982\uff1a function myFunction(&amp;$array) { \/\/ \u4ee3\u7801\u5728\u8fd9\u91cc } \u4f7f\u7528\u6848\u4f8b\uff1a\u4fee\u6539\u6570\u7ec4 \u8003\u8651\u4e00\u4e2a\u5305\u542b\u540d\u79f0\u548c\u5730\u5740\u4fe1\u606f\u7684\u6570\u7ec4\uff1a $people = [ [&#8216;name&#8217; =&gt; &#8216;John&#8217;, &#8216;address&#8217; =&gt; &#8216;123 Main St&#8217;], [&#8216;name&#8217; =&gt; &#8216;Mary&#8217;, &#8216;address&#8217; =&gt; &#8216;456 Elm St&#8217;], ]; \u6211\u4eec\u5e0c\u671b\u521b\u5efa\u4e00\u4e2a\u51fd\u6570\u6765\u66f4\u65b0\u6bcf\u4e2a\u4eba\u7684\u5730\u5740\u3002\u6309\u503c\u4f20\u9012\u5c06\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u6570\u7ec4\u526f\u672c\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5f88\u4f4e\u6548\u3002\u76f8\u53cd\uff0c\u6211\u4eec\u53ef\u4ee5\u6309\u5f15\u7528\u4f20\u9012\u6570\u7ec4\uff0c\u5982\u4e0b\u6240\u793a\uff1a function updateAddresses(&amp;$people) { foreach ($people as &amp;$person) [&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-47475","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47475","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=47475"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47475\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=47475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=47475"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=47475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}