{"id":47924,"date":"2024-12-02T13:32:16","date_gmt":"2024-12-02T05:32:16","guid":{"rendered":"https:\/\/fwq.ai\/blog\/47924\/"},"modified":"2024-12-02T13:32:16","modified_gmt":"2024-12-02T05:32:16","slug":"%e6%b7%b1%e5%85%a5%e6%b5%85%e5%87%ba%ef%bc%9aphp-%e5%87%bd%e6%95%b0%e4%b8%ad%e5%bc%95%e7%94%a8%e4%bc%a0%e9%80%92%e7%9a%84%e6%9c%ba%e5%88%b6","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/47924\/","title":{"rendered":"\u6df1\u5165\u6d45\u51fa\uff1aPHP \u51fd\u6570\u4e2d\u5f15\u7528\u4f20\u9012\u7684\u673a\u5236"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u6df1\u5165\u6d45\u51fa\uff1aPHP \u51fd\u6570\u4e2d\u5f15\u7528\u4f20\u9012\u7684\u673a\u5236<\/h1>\n<p>\u600e\u4e48\u5165\u95e8\u6587\u7ae0\u7f16\u7a0b\uff1f\u9700\u8981\u5b66\u4e60\u54ea\u4e9b\u77e5\u8bc6\u70b9\uff1f\u8fd9\u662f\u65b0\u624b\u4eec\u521a\u63a5\u89e6\u7f16\u7a0b\u65f6\u5e38\u89c1\u7684\u95ee\u9898\uff1b\u4e0b\u9762\u7c73\u4e91\u5c31\u6765\u7ed9\u5927\u5bb6\u6574\u7406\u5206\u4eab\u4e00\u4e9b\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u80fd\u591f\u7ed9\u521d\u5b66\u8005\u4e00\u4e9b\u5e2e\u52a9\u3002\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u4ecb\u7ecd\u300a\u6df1\u5165\u6d45\u51fa\uff1aPHP \u51fd\u6570\u4e2d\u5f15\u7528\u4f20\u9012\u7684\u673a\u5236\u300b\uff0c\u6d89\u53ca\u5230\uff0c\u6709\u9700\u8981\u7684\u53ef\u4ee5\u6536\u85cf\u4e00\u4e0b<\/p>\n<p>\u5728 PHP \u4e2d\uff0c\u51fd\u6570\u53ef\u4ee5\u6309\u503c\u6216\u6309\u5f15\u7528\u4f20\u9012\u53d8\u91cf\u3002\u6309\u503c\u4f20\u9012\u590d\u5236\u53d8\u91cf\u7684\u503c\uff0c\u6309\u5f15\u7528\u4f20\u9012\u4f20\u9012\u53d8\u91cf\u7684\u5f15\u7528\u672c\u8eab\u3002\u6309\u5f15\u7528\u4f20\u9012\u9700\u8981\u5728\u53c2\u6570\u524d\u4f7f\u7528 &amp; \u7b26\u53f7\u3002\u6309\u5f15\u7528\u4f20\u9012\u53d8\u91cf\u7684\u597d\u5904\u662f\u51fd\u6570\u53ef\u4ee5\u4fee\u6539\u539f\u59cb\u53d8\u91cf\u7684\u503c\u3002\u4f46\u9700\u8981\u6ce8\u610f\u6309\u5f15\u7528\u4f20\u9012\u4f1a\u4f7f\u4ee3\u7801\u66f4\u96be\u8c03\u8bd5\uff0c\u5e76\u53ef\u80fd\u5bfc\u81f4\u5bf9\u8c61\u5faa\u73af\u5f15\u7528\u548c\u5185\u5b58\u6cc4\u6f0f\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241026\/1729943441671cd79151d8e.jpg\" class=\"aligncenter\" title=\"\u6df1\u5165\u6d45\u51fa\uff1aPHP \u51fd\u6570\u4e2d\u5f15\u7528\u4f20\u9012\u7684\u673a\u5236\u63d2\u56fe\" alt=\"\u6df1\u5165\u6d45\u51fa\uff1aPHP \u51fd\u6570\u4e2d\u5f15\u7528\u4f20\u9012\u7684\u673a\u5236\u63d2\u56fe\" \/><\/p>\n<p><strong>\u6df1\u5165\u6d45\u51fa\uff1aPHP \u51fd\u6570\u4e2d\u5f15\u7528\u4f20\u9012\u7684\u673a\u5236<\/strong><\/p>\n<p>\u5728 PHP \u4e2d\uff0c\u51fd\u6570\u53ef\u4ee5\u6309\u503c\u4f20\u9012\u6216\u6309\u5f15\u7528\u4f20\u9012\u53d8\u91cf\u3002\u6309\u503c\u4f20\u9012\u590d\u5236\u53d8\u91cf\u7684\u503c\uff0c\u800c\u6309\u5f15\u7528\u4f20\u9012\u5219\u4f20\u9012\u53d8\u91cf\u7684\u5f15\u7528\u672c\u8eab\u3002<\/p>\n<p><strong>\u6309\u503c\u4f20\u9012<\/strong><\/p>\n<pre>function setValue($val) {\n  $val = 10;\n}\n\n$a = 5;\nsetValue($a);\necho $a; \/\/ \u8f93\u51fa\uff1a5<\/pre>\n<p><code>setValue()<\/code> \u51fd\u6570\u4f5c\u7528\u4e8e\u53d8\u91cf <code>$val<\/code> \u7684\u526f\u672c\uff0c\u56e0\u6b64\u5bf9\u526f\u672c\u7684\u4fee\u6539\u4e0d\u4f1a\u5f71\u54cd\u53d8\u91cf <code>$a<\/code> \u7684\u539f\u59cb\u503c\u3002<\/p>\n<p><strong>\u6309\u5f15\u7528\u4f20\u9012<\/strong><\/p>\n<p>\u8981\u6309\u5f15\u7528\u4f20\u9012\u53d8\u91cf\uff0c\u9700\u8981\u5728\u53c2\u6570\u524d\u4f7f\u7528\u7b26\u53f7 <code>&amp;<\/code>\u3002<\/p>\n<pre>function setRef(&amp;$val) {\n  $val = 10;\n}\n\n$a = 5;\nsetRef($a);\necho $a; \/\/ \u8f93\u51fa\uff1a10<\/pre>\n<p><code>setRef()<\/code> \u51fd\u6570\u4f5c\u7528\u4e8e\u53d8\u91cf <code>$a<\/code> \u7684\u5f15\u7528\uff0c\u56e0\u6b64\u5bf9\u5f15\u7528\u503c\u7684\u4fee\u6539\u4e5f\u4f1a\u4fee\u6539\u53d8\u91cf <code>$a<\/code> \u7684\u539f\u59cb\u503c\u3002<\/p>\n<p><strong>\u5b9e\u6218\u6848\u4f8b<\/strong><\/p>\n<p>\u4ee5\u4e0b\u793a\u4f8b\u5c55\u793a\u4e86\u6309\u5f15\u7528\u4f20\u9012\u6570\u7ec4\uff1a<\/p>\n<pre>function modifyArray(&amp;$arr) {\n  $arr[] = 10;\n}\n\n$arr = [1, 2, 3];\nmodifyArray($arr);\nprint_r($arr); \/\/ \u8f93\u51fa\uff1a[1, 2, 3, 10]<\/pre>\n<p><code>modifyArray()<\/code> \u51fd\u6570\u4f5c\u7528\u4e8e\u6570\u7ec4 <code>$arr<\/code> \u7684\u5f15\u7528\uff0c\u56e0\u6b64\u5728\u51fd\u6570\u4e2d\u5bf9\u6570\u7ec4\u7684\u4fee\u6539\u4f1a\u53cd\u6620\u5728\u539f\u59cb\u6570\u7ec4\u4e2d\u3002<\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879<\/strong><\/p>\n<ul>\n<li>\u6309\u5f15\u7528\u4f20\u9012\u4f1a\u4f7f\u4ee3\u7801\u66f4\u96be\u8c03\u8bd5\uff0c\u56e0\u4e3a\u53d8\u91cf\u7684\u503c\u53ef\u4ee5\u5728\u51fd\u6570\u5916\u610f\u5916\u6539\u53d8\u3002<\/li>\n<li>\u4ec5\u5728\u9700\u8981\u4fee\u6539\u51fd\u6570\u5916\u90e8\u53d8\u91cf\u65f6\u624d\u4f7f\u7528\u6309\u5f15\u7528\u4f20\u9012\u3002<\/li>\n<li>\u5728\u6309\u5f15\u7528\u4f20\u9012\u5bf9\u8c61\u65f6\u8981\u5c0f\u5fc3\uff0c\u56e0\u4e3a\u8fd9\u53ef\u80fd\u5bfc\u81f4\u5bf9\u8c61\u5faa\u73af\u5f15\u7528\u548c\u5185\u5b58\u6cc4\u6f0f\u3002<\/li>\n<\/ul>\n<p>\u6587\u4e2d\u5173\u4e8ephp,\u5f15\u7528\u4f20\u9012\u7684\u77e5\u8bc6\u4ecb\u7ecd\uff0c\u5e0c\u671b\u5bf9\u4f60\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9\uff01\u82e5\u662f\u53d7\u76ca\u532a\u6d45\uff0c\u90a3\u5c31\u52a8\u52a8\u9f20\u6807\u6536\u85cf\u8fd9\u7bc7\u300a\u6df1\u5165\u6d45\u51fa\uff1aPHP \u51fd\u6570\u4e2d\u5f15\u7528\u4f20\u9012\u7684\u673a\u5236\u300b\u6587\u7ae0\u5427\uff0c\u4e5f\u53ef\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\u4e86\u89e3\u76f8\u5173\u6280\u672f\u6587\u7ae0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6df1\u5165\u6d45\u51fa\uff1aPHP \u51fd\u6570\u4e2d\u5f15\u7528\u4f20\u9012\u7684\u673a\u5236 \u600e\u4e48\u5165\u95e8\u6587\u7ae0\u7f16\u7a0b\uff1f\u9700\u8981\u5b66\u4e60\u54ea\u4e9b\u77e5\u8bc6\u70b9\uff1f\u8fd9\u662f\u65b0\u624b\u4eec\u521a\u63a5\u89e6\u7f16\u7a0b\u65f6\u5e38\u89c1\u7684\u95ee\u9898\uff1b\u4e0b\u9762\u7c73\u4e91\u5c31\u6765\u7ed9\u5927\u5bb6\u6574\u7406\u5206\u4eab\u4e00\u4e9b\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u80fd\u591f\u7ed9\u521d\u5b66\u8005\u4e00\u4e9b\u5e2e\u52a9\u3002\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u4ecb\u7ecd\u300a\u6df1\u5165\u6d45\u51fa\uff1aPHP \u51fd\u6570\u4e2d\u5f15\u7528\u4f20\u9012\u7684\u673a\u5236\u300b\uff0c\u6d89\u53ca\u5230\uff0c\u6709\u9700\u8981\u7684\u53ef\u4ee5\u6536\u85cf\u4e00\u4e0b \u5728 PHP \u4e2d\uff0c\u51fd\u6570\u53ef\u4ee5\u6309\u503c\u6216\u6309\u5f15\u7528\u4f20\u9012\u53d8\u91cf\u3002\u6309\u503c\u4f20\u9012\u590d\u5236\u53d8\u91cf\u7684\u503c\uff0c\u6309\u5f15\u7528\u4f20\u9012\u4f20\u9012\u53d8\u91cf\u7684\u5f15\u7528\u672c\u8eab\u3002\u6309\u5f15\u7528\u4f20\u9012\u9700\u8981\u5728\u53c2\u6570\u524d\u4f7f\u7528 &amp; \u7b26\u53f7\u3002\u6309\u5f15\u7528\u4f20\u9012\u53d8\u91cf\u7684\u597d\u5904\u662f\u51fd\u6570\u53ef\u4ee5\u4fee\u6539\u539f\u59cb\u53d8\u91cf\u7684\u503c\u3002\u4f46\u9700\u8981\u6ce8\u610f\u6309\u5f15\u7528\u4f20\u9012\u4f1a\u4f7f\u4ee3\u7801\u66f4\u96be\u8c03\u8bd5\uff0c\u5e76\u53ef\u80fd\u5bfc\u81f4\u5bf9\u8c61\u5faa\u73af\u5f15\u7528\u548c\u5185\u5b58\u6cc4\u6f0f\u3002 \u6df1\u5165\u6d45\u51fa\uff1aPHP \u51fd\u6570\u4e2d\u5f15\u7528\u4f20\u9012\u7684\u673a\u5236 \u5728 PHP \u4e2d\uff0c\u51fd\u6570\u53ef\u4ee5\u6309\u503c\u4f20\u9012\u6216\u6309\u5f15\u7528\u4f20\u9012\u53d8\u91cf\u3002\u6309\u503c\u4f20\u9012\u590d\u5236\u53d8\u91cf\u7684\u503c\uff0c\u800c\u6309\u5f15\u7528\u4f20\u9012\u5219\u4f20\u9012\u53d8\u91cf\u7684\u5f15\u7528\u672c\u8eab\u3002 \u6309\u503c\u4f20\u9012 function setValue($val) { $val = 10; } $a = 5; setValue($a); echo $a; \/\/ \u8f93\u51fa\uff1a5 setValue() \u51fd\u6570\u4f5c\u7528\u4e8e\u53d8\u91cf $val \u7684\u526f\u672c\uff0c\u56e0\u6b64\u5bf9\u526f\u672c\u7684\u4fee\u6539\u4e0d\u4f1a\u5f71\u54cd\u53d8\u91cf $a \u7684\u539f\u59cb\u503c\u3002 \u6309\u5f15\u7528\u4f20\u9012 \u8981\u6309\u5f15\u7528\u4f20\u9012\u53d8\u91cf\uff0c\u9700\u8981\u5728\u53c2\u6570\u524d\u4f7f\u7528\u7b26\u53f7 &amp;\u3002 function setRef(&amp;$val) { $val = 10; } $a = 5; setRef($a); echo $a; \/\/ \u8f93\u51fa\uff1a10 setRef() [&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-47924","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47924","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=47924"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47924\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=47924"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=47924"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=47924"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}