{"id":47844,"date":"2024-12-02T12:26:47","date_gmt":"2024-12-02T04:26:47","guid":{"rendered":"https:\/\/fwq.ai\/blog\/47844\/"},"modified":"2024-12-02T12:26:47","modified_gmt":"2024-12-02T04:26:47","slug":"php-%e5%87%bd%e6%95%b0%e4%b8%ad%e4%bc%a0%e9%80%92%e5%bc%95%e7%94%a8%e8%bf%98%e6%98%af%e5%80%bc%e6%9c%89%e4%bd%95%e5%8c%ba%e5%88%ab","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/47844\/","title":{"rendered":"PHP \u51fd\u6570\u4e2d\u4f20\u9012\u5f15\u7528\u8fd8\u662f\u503c\u6709\u4f55\u533a\u522b"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>PHP \u51fd\u6570\u4e2d\u4f20\u9012\u5f15\u7528\u8fd8\u662f\u503c\u6709\u4f55\u533a\u522b<\/h1>\n<p><span style=\"font-size: 15px\">\u6709\u5fd7\u8005\uff0c\u4e8b\u7adf\u6210\uff01\u5982\u679c\u4f60\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\uff0c\u90a3\u4e48\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aPHP \u51fd\u6570\u4e2d\u4f20\u9012\u5f15\u7528\u8fd8\u662f\u503c\u6709\u4f55\u533a\u522b\u300b<\/span>\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff01\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\uff0c\u82e5\u662f\u4f60\u5bf9\u672c\u6587\u611f\u5174\u8da3\uff0c\u6216\u8005\u662f\u60f3\u641e\u61c2\u5176\u4e2d\u67d0\u4e2a\u77e5\u8bc6\u70b9\uff0c\u5c31\u8bf7\u4f60\u7ee7\u7eed\u5f80\u4e0b\u770b\u5427~<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241026\/1729939404671cc7cc424b7.jpg\" class=\"aligncenter\" title=\"PHP \u51fd\u6570\u4e2d\u4f20\u9012\u5f15\u7528\u8fd8\u662f\u503c\u6709\u4f55\u533a\u522b\u63d2\u56fe\" alt=\"PHP \u51fd\u6570\u4e2d\u4f20\u9012\u5f15\u7528\u8fd8\u662f\u503c\u6709\u4f55\u533a\u522b\u63d2\u56fe\" \/><\/p>\n<p><strong>PHP \u51fd\u6570\u4e2d\u4f20\u9012\u5f15\u7528\u4e0e\u503c\u7684\u533a\u522b<\/strong><\/p>\n<p>\u5728 PHP \u51fd\u6570\u4e2d\uff0c\u4f20\u9012\u53c2\u6570\u65f6\u65e2\u53ef\u4ee5\u4f20\u9012\u5f15\u7528\uff0c\u4e5f\u53ef\u4ee5\u4f20\u9012\u503c\u3002\u4e24\u8005\u4e4b\u95f4\u6709\u5fae\u5999\u7684\u533a\u522b\uff0c\u7406\u89e3\u8fd9\u4e9b\u533a\u522b\u81f3\u5173\u91cd\u8981\u3002<\/p>\n<p><strong>\u4f20\u9012\u503c<\/strong><\/p>\n<p>\u5f53\u4ee5\u503c\u7684\u5f62\u5f0f\u4f20\u9012\u53c2\u6570\u65f6\uff0c\u51fd\u6570\u4f1a\u521b\u5efa\u4e00\u4e2a\u8be5\u53c2\u6570\u7684\u526f\u672c\u3002\u5bf9\u8be5\u526f\u672c\u6240\u505a\u7684\u4efb\u4f55\u66f4\u6539\u90fd\u4e0d\u4f1a\u5f71\u54cd\u8c03\u7528\u51fd\u6570\u4e2d\u7684\u539f\u59cb\u53d8\u91cf\u3002<\/p>\n<pre>function sumValues($a, $b) {\n  $a += 10;\n  $b += 20;\n}\n\n$x = 10;\n$y = 20;\n\nsumValues($x, $y);\n\necho $x; \/\/ \u8f93\u51fa 10\necho $y; \/\/ \u8f93\u51fa 20<\/pre>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>sumValues<\/code> \u51fd\u6570\u63a5\u6536 <code>$a<\/code> \u548c <code>$b<\/code> \u7684\u503c\uff0c\u5e76\u5bf9\u5b83\u4eec\u7684\u526f\u672c\u6267\u884c\u52a0\u6cd5\u64cd\u4f5c\u3002\u5bf9\u8fd9\u4e9b\u526f\u672c\u7684\u66f4\u6539\u4e0d\u4f1a\u5f71\u54cd <code>$x<\/code> \u548c <code>$y<\/code> \u7684\u539f\u59cb\u503c\u3002<\/p>\n<p><strong>\u4f20\u9012\u5f15\u7528<\/strong><\/p>\n<p>\u5f53\u4ee5\u5f15\u7528\u7684\u5f62\u5f0f\u4f20\u9012\u53c2\u6570\u65f6\uff0c\u51fd\u6570\u4f1a\u83b7\u53d6\u5bf9\u8c03\u7528\u51fd\u6570\u4e2d\u539f\u59cb\u53d8\u91cf\u7684\u5f15\u7528\u3002\u5bf9\u8be5\u5f15\u7528\u7684\u4efb\u4f55\u66f4\u6539\u90fd\u4f1a\u5f71\u54cd\u539f\u59cb\u53d8\u91cf\u3002<\/p>\n<pre>function sumValuesByReference(&amp;$a, &amp;$b) {\n  $a += 10;\n  $b += 20;\n}\n\n$x = 10;\n$y = 20;\n\nsumValuesByReference($x, $y);\n\necho $x; \/\/ \u8f93\u51fa 20\necho $y; \/\/ \u8f93\u51fa 40<\/pre>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>sumValuesByReference<\/code> \u51fd\u6570\u63a5\u6536 <code>$a<\/code> \u548c <code>$b<\/code> \u7684\u5f15\u7528\u3002\u901a\u8fc7\u5f15\u7528\u66f4\u6539\u8fd9\u4e9b\u53d8\u91cf\u4f1a\u5f71\u54cd <code>$x<\/code> \u548c <code>$y<\/code> \u7684\u539f\u59cb\u503c\u3002<\/p>\n<p><strong>\u5b9e\u6218\u6848\u4f8b<\/strong><\/p>\n<p>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u51fd\u6570\u9700\u8981\u4fee\u6539\u4e00\u4e2a\u6570\u7ec4\uff1a<\/p>\n<pre>function modifyArray($arr) {\n  $arr[] = 'new_element';\n}\n\n$arr = ['a', 'b', 'c'];\nmodifyArray($arr);\n\nprint_r($arr);<\/pre>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>modifyArray<\/code> \u51fd\u6570\u4f20\u9012\u7684\u662f\u8be5\u6570\u7ec4\u7684\u503c\u3002\u5bf9\u526f\u672c\u7684\u66f4\u6539\u4e0d\u4f1a\u5f71\u54cd\u539f\u59cb\u6570\u7ec4\u3002\u8f93\u51fa\u7ed3\u679c\u5c06\u662f <code>['a', 'b', 'c']<\/code>\u3002<\/p>\n<p>\u5982\u679c\u6211\u4eec\u60f3\u8981\u4fee\u6539\u539f\u59cb\u6570\u7ec4\uff0c\u6211\u4eec\u53ef\u4ee5\u4f20\u9012\u8be5\u6570\u7ec4\u7684\u5f15\u7528\uff1a<\/p>\n<pre>function modifyArrayByReference(&amp;$arr) {\n  $arr[] = 'new_element';\n}\n\n$arr = ['a', 'b', 'c'];\nmodifyArrayByReference($arr);\n\nprint_r($arr);<\/pre>\n<p>\u8fd9\u6b21\uff0c\u8f93\u51fa\u7ed3\u679c\u5c06\u662f <code>['a', 'b', 'c', 'new_element']<\/code>\uff0c\u56e0\u4e3a\u5bf9\u8be5\u5f15\u7528\u7684\u66f4\u6539\u5b9e\u8d28\u4e0a\u662f\u4fee\u6539\u4e86\u539f\u59cb\u6570\u7ec4\u3002<\/p>\n<p>\u7406\u8bba\u8981\u638c\u63e1\uff0c\u5b9e\u64cd\u4e0d\u80fd\u843d\uff01\u4ee5\u4e0a\u5173\u4e8e\u300aPHP \u51fd\u6570\u4e2d\u4f20\u9012\u5f15\u7528\u8fd8\u662f\u503c\u6709\u4f55\u533a\u522b\u300b\u7684\u8be6\u7ec6\u4ecb\u7ecd\uff0c\u5927\u5bb6\u90fd\u638c\u63e1\u4e86\u5427\uff01\u5982\u679c\u60f3\u8981\u7ee7\u7eed\u63d0\u5347\u81ea\u5df1\u7684\u80fd\u529b\uff0c\u90a3\u4e48\u5c31\u6765\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\u5427\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP \u51fd\u6570\u4e2d\u4f20\u9012\u5f15\u7528\u8fd8\u662f\u503c\u6709\u4f55\u533a\u522b \u6709\u5fd7\u8005\uff0c\u4e8b\u7adf\u6210\uff01\u5982\u679c\u4f60\u5728\u5b66\u4e60\u6587\u7ae0\uff0c\u90a3\u4e48\u672c\u6587\u300aPHP \u51fd\u6570\u4e2d\u4f20\u9012\u5f15\u7528\u8fd8\u662f\u503c\u6709\u4f55\u533a\u522b\u300b\uff0c\u5c31\u5f88\u9002\u5408\u4f60\uff01\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\uff0c\u82e5\u662f\u4f60\u5bf9\u672c\u6587\u611f\u5174\u8da3\uff0c\u6216\u8005\u662f\u60f3\u641e\u61c2\u5176\u4e2d\u67d0\u4e2a\u77e5\u8bc6\u70b9\uff0c\u5c31\u8bf7\u4f60\u7ee7\u7eed\u5f80\u4e0b\u770b\u5427~ PHP \u51fd\u6570\u4e2d\u4f20\u9012\u5f15\u7528\u4e0e\u503c\u7684\u533a\u522b \u5728 PHP \u51fd\u6570\u4e2d\uff0c\u4f20\u9012\u53c2\u6570\u65f6\u65e2\u53ef\u4ee5\u4f20\u9012\u5f15\u7528\uff0c\u4e5f\u53ef\u4ee5\u4f20\u9012\u503c\u3002\u4e24\u8005\u4e4b\u95f4\u6709\u5fae\u5999\u7684\u533a\u522b\uff0c\u7406\u89e3\u8fd9\u4e9b\u533a\u522b\u81f3\u5173\u91cd\u8981\u3002 \u4f20\u9012\u503c \u5f53\u4ee5\u503c\u7684\u5f62\u5f0f\u4f20\u9012\u53c2\u6570\u65f6\uff0c\u51fd\u6570\u4f1a\u521b\u5efa\u4e00\u4e2a\u8be5\u53c2\u6570\u7684\u526f\u672c\u3002\u5bf9\u8be5\u526f\u672c\u6240\u505a\u7684\u4efb\u4f55\u66f4\u6539\u90fd\u4e0d\u4f1a\u5f71\u54cd\u8c03\u7528\u51fd\u6570\u4e2d\u7684\u539f\u59cb\u53d8\u91cf\u3002 function sumValues($a, $b) { $a += 10; $b += 20; } $x = 10; $y = 20; sumValues($x, $y); echo $x; \/\/ \u8f93\u51fa 10 echo $y; \/\/ \u8f93\u51fa 20 \u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0csumValues \u51fd\u6570\u63a5\u6536 $a \u548c $b \u7684\u503c\uff0c\u5e76\u5bf9\u5b83\u4eec\u7684\u526f\u672c\u6267\u884c\u52a0\u6cd5\u64cd\u4f5c\u3002\u5bf9\u8fd9\u4e9b\u526f\u672c\u7684\u66f4\u6539\u4e0d\u4f1a\u5f71\u54cd $x \u548c $y \u7684\u539f\u59cb\u503c\u3002 \u4f20\u9012\u5f15\u7528 \u5f53\u4ee5\u5f15\u7528\u7684\u5f62\u5f0f\u4f20\u9012\u53c2\u6570\u65f6\uff0c\u51fd\u6570\u4f1a\u83b7\u53d6\u5bf9\u8c03\u7528\u51fd\u6570\u4e2d\u539f\u59cb\u53d8\u91cf\u7684\u5f15\u7528\u3002\u5bf9\u8be5\u5f15\u7528\u7684\u4efb\u4f55\u66f4\u6539\u90fd\u4f1a\u5f71\u54cd\u539f\u59cb\u53d8\u91cf\u3002 function sumValuesByReference(&amp;$a, &amp;$b) [&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-47844","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47844","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=47844"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/47844\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=47844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=47844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=47844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}