{"id":182893,"date":"2024-05-08T21:32:04","date_gmt":"2024-05-08T13:32:04","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/182893.html"},"modified":"2024-05-08T21:32:21","modified_gmt":"2024-05-08T13:32:21","slug":"php%e4%b8%ad%e7%9a%84%e9%97%ad%e5%8c%85%e6%9c%89%e4%bb%80%e4%b9%88%e7%94%a8%e5%a4%84","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/182893.html","title":{"rendered":"PHP\u4e2d\u7684\u95ed\u5305\u6709\u4ec0\u4e48\u7528\u5904"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27073240\/e3fb340b-2c61-4606-9c7f-a49fcbc4011b.webp\" alt=\"PHP\u4e2d\u7684\u95ed\u5305\u6709\u4ec0\u4e48\u7528\u5904\" \/><\/p>\n<p><p>\u95ed\u5305\u5728PHP\u4e2d\u4e3b\u8981\u7528\u4e8e \u5305\u88c5\u7279\u5b9a\u7684\u529f\u80fd\u4ee3\u7801\u5757\uff0c\u4ee5\u4fbf\u5b83\u4eec\u53ef\u4ee5\u5728\u4e00\u4e2a\u53d8\u91cf\u4e2d\u4f20\u9012\u548c\u4f7f\u7528\u3001\u4e3a\u51fd\u6570\u521b\u5efa\u4e00\u4e2a\u7279\u5b9a\u7684\u4f5c\u7528\u57df\u6216\u8005\u7ed1\u5b9a\u5bf9\u8c61\uff0c\u4ece\u800c\u4f7f\u5f97\u539f\u672c\u4f5c\u7528\u57df\u4ee5\u5916\u7684\u53d8\u91cf\u53ef\u4ee5\u5728\u51fd\u6570\u5185\u90e8\u88ab\u4f7f\u7528\u3001\u5b9e\u73b0\u56de\u8c03\u51fd\u6570\u548c\u9ad8\u9636\u51fd\u6570\uff0c\u63d0\u9ad8\u4ee3\u7801\u6a21\u5757\u5316\u548c\u590d\u7528\u6027\u3001\u5e2e\u52a9\u5b9e\u73b0\u4f9d\u8d56\u6ce8\u5165\u548c\u4e2d\u95f4\u4ef6\u7b49\u8bbe\u8ba1\u6a21\u5f0f\u3001\u5141\u8bb8\u524d\u4e00\u4e2a\u51fd\u6570\u7684\u5c40\u90e8\u53d8\u91cf\u5728\u540e\u7eed\u533f\u540d\u51fd\u6570\u4e2d\u4fdd\u6301\u72b6\u6001\uff0c\u8fd9\u5bf9\u521b\u5efa\u751f\u6210\u5668\u6216\u8005\u8fed\u4ee3\u5668\u975e\u5e38\u6709\u7528\u3002\u95ed\u5305\u7684\u8fd9\u4e9b\u7528\u5904\u4f7f\u5f97\u5b83\u5728\u73b0\u4ee3PHP\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u53d8\u5f97\u6781\u5176\u91cd\u8981\u548c\u5e7f\u6cdb\u3002<\/p>\n<\/p>\n<p><p>\u95ed\u5305\u53ef\u4ee5\u7ed9\u7a0b\u5e8f\u5e26\u6765\u6781\u5927\u7684\u7075\u6d3b\u6027\u548c\u8868\u8fbe\u529b\u3002<strong>\u5c24\u5176\u662f\u5728\u6570\u636e\u5c01\u88c5\u548c\u4f5c\u7528\u57df\u9694\u79bb\u65b9\u9762<\/strong>\uff0c\u95ed\u5305\u53ef\u4ee5\u521b\u5efa\u72ec\u7acb\u7684\u4f5c\u7528\u57df\uff0c\u8fd9\u4f7f\u5f97\u5b83\u4eec\u53ef\u4ee5\u9690\u85cf\u548c\u4fdd\u62a4\u53d8\u91cf\uff0c\u907f\u514d\u4e86\u5168\u5c40\u547d\u540d\u7a7a\u95f4\u7684\u6c61\u67d3\u3002\u4f8b\u5982\uff0c\u4e00\u4e2a\u5e38\u89c1\u7684\u7528\u6cd5\u662f\u5728\u4e00\u4e2a\u51fd\u6570\u5185\u90e8\u5b9a\u4e49\u53e6\u4e00\u4e2a\u51fd\u6570\uff0c\u5373\u4e00\u4e2a\u95ed\u5305\uff0c\u8fd9\u6837\u5185\u90e8\u51fd\u6570\u53ef\u4ee5\u8bbf\u95ee\u5916\u90e8\u51fd\u6570\u7684\u53d8\u91cf\uff0c\u4f46\u662f\u8fd9\u4e9b\u53d8\u91cf\u5728\u5916\u90e8\u5374\u662f\u4e0d\u53ef\u89c1\u7684\u3002\u8fd9\u6837\u7684\u8bbe\u8ba1\u5728\u5f00\u53d1\u5927\u578b\u5e94\u7528\u7a0b\u5e8f\u65f6\u7279\u522b\u6709\u5229\uff0c\u80fd\u591f\u9650\u5236\u548c\u7ba1\u7406\u53d8\u91cf\u7684\u8bbf\u95ee\u7ea7\u522b\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u95ed\u5305\u63d0\u4f9b\u4e86\u529f\u80fd\u5c01\u88c5<\/h3>\n<\/p>\n<p><p><strong>\u95ed\u5305\u4f7f\u5f00\u53d1\u8005\u80fd\u591f\u5c06\u76f8\u5173\u7684\u5904\u7406\u903b\u8f91\u5c01\u88c5\u5728\u4e00\u8d77<\/strong>\uff0c\u5f62\u6210\u4e00\u4e2a\u5355\u5143\u3002\u5728PHP\u4e2d\uff0c\u95ed\u5305\u901a\u5e38\u4ee5\u533f\u540d\u51fd\u6570\u7684\u5f62\u5f0f\u5b9e\u73b0\uff0c\u8fd9\u5141\u8bb8\u5c06\u51fd\u6570\u8d4b\u4e88\u7ed9\u53d8\u91cf\uff0c\u5c06\u5176\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\uff0c\u6216\u8005\u4f5c\u4e3a\u5176\u4ed6\u51fd\u6570\u7684\u8fd4\u56de\u503c\u3002\u8fd9\u79cd\u5c01\u88c5\u4e0d\u4ec5\u6709\u52a9\u4e8e\u4fdd\u6301\u4ee3\u7801\u7684\u6574\u6d01\u6027\uff0c\u800c\u4e14\u4fc3\u8fdb\u4e86\u6a21\u5757\u5316\u8bbe\u8ba1\u3002<\/p>\n<\/p>\n<p><p>\u8981\u5c01\u88c5\u4e00\u4e2a\u529f\u80fd\u903b\u8f91\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u6839\u636e\u9700\u8981\uff0c\u5728\u51fd\u6570\u5185\u90e8\u58f0\u660e\u53d8\u91cf\uff0c\u5904\u7406\u6570\u636e\uff0c\u7136\u540e\u5c06\u7ed3\u679c\u8fd4\u56de\u3002\u95ed\u5305\u7684\u8fd9\u79cd\u72ec\u7acb\u6027\u4f7f\u5176\u6210\u4e3a\u521b\u5efa\u5c0f\u578b\u529f\u80fd\u6a21\u5757\u7684\u7406\u60f3\u9009\u62e9\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u95ed\u5305\u7684\u4f5c\u7528\u57df\u63a7\u5236<\/h3>\n<\/p>\n<p><p><strong>\u95ed\u5305\u5728PHP\u4e2d\u63d0\u4f9b\u4e86\u4e00\u79cd\u5f3a\u5927\u7684\u4f5c\u7528\u57df\u63a7\u5236\u673a\u5236<\/strong>\u3002\u533f\u540d\u51fd\u6570\u80fd\u591f\u4ece\u7236\u4f5c\u7528\u57df\u4e2d\u7ee7\u627f\u53d8\u91cf\uff0c\u8fd9\u79cd\u7279\u6027\u4f7f\u5f97\u95ed\u5305\u80fd\u591f\u5728\u4e0d\u4fee\u6539\u5168\u5c40\u4f5c\u7528\u57df\u7684\u60c5\u51b5\u4e0b\u5de5\u4f5c\u3002<code>use<\/code>\u5173\u952e\u5b57\u5728\u8fd9\u91cc\u8d77\u5230\u5173\u952e\u4f5c\u7528\uff0c\u5b83\u5141\u8bb8\u95ed\u5305\u4ece\u5b9a\u4e49\u5b83\u7684\u4f5c\u7528\u57df\u4e2d\u7ee7\u627f\u53d8\u91cf\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u95ed\u5305\u53ef\u7528\u4e8e\u4fee\u6539\u6216\u6269\u5c55\u90a3\u4e9b\u4e0d\u5bb9\u6613\u76f4\u63a5\u8bbf\u95ee\u7684\u5c40\u90e8\u53d8\u91cf\u7684\u884c\u4e3a\u3002\u901a\u8fc7\u95ed\u5305\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u533f\u540d\u51fd\u6570\u4e2d\u6355\u83b7\u8fd9\u4e9b\u53d8\u91cf\u7684\u72b6\u6001\uff0c\u5e76\u5728\u4e0d\u540c\u7684\u4e0a\u4e0b\u6587\u4e2d\u590d\u7528\u8fd9\u4e2a\u72b6\u6001\u548c\u903b\u8f91\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u95ed\u5305\u5728\u56de\u8c03\u51fd\u6570\u4e2d\u7684\u5e94\u7528<\/h3>\n<\/p>\n<p><p><strong>\u95ed\u5305\u5e38\u4f5c\u4e3a\u56de\u8c03\u51fd\u6570\uff0c\u589e\u5f3aPHP\u4e2d\u4e8b\u4ef6\u9a71\u52a8\u7f16\u7a0b\u7684\u80fd\u529b<\/strong>\u3002\u7531\u4e8e\u95ed\u5305\u53ef\u4ee5\u4f5c\u4e3a\u53d8\u91cf\u4f20\u9012\uff0c\u56e0\u6b64\u5b83\u4eec\u975e\u5e38\u9002\u5408\u4f5c\u4e3a\u8c03\u7528\u7528\u6237\u51fd\u6570\u7684\u53c2\u6570\u3002\u5728\u5982\u6392\u5e8f (<code>usort<\/code>)\u3001\u6570\u7ec4\u6620\u5c04 (<code>array_map<\/code>)\u7b49\u51fd\u6570\u4e2d\uff0c\u95ed\u5305\u4f5c\u4e3a\u56de\u8c03\u51fd\u6570\uff0c\u63d0\u4f9b\u4e86\u4e00\u79cd\u975e\u5e38\u65b9\u4fbf\u7684\u65b9\u5f0f\u53bb\u5b9a\u5236\u548c\u63a7\u5236\u51fd\u6570\u7684\u884c\u4e3a\u3002<\/p>\n<\/p>\n<p><p>\u8fd9\u79cd\u7528\u9014\u4f53\u73b0\u4e86\u95ed\u5305\u4e0e\u4f20\u7edf\u51fd\u6570\u5b9a\u4e49\u7684\u4e00\u4e2a\u5173\u952e\u4e0d\u540c\uff1a\u95ed\u5305\u80fd\u88ab\u8d4b\u4e88\u53d8\u91cf\uff0c\u5e76\u88ab\u4f20\u9012\u548c\u8c03\u7528\uff0c\u800c\u4e0d\u4ec5\u4ec5\u662f\u5728\u5b83\u88ab\u5b9a\u4e49\u7684\u5730\u65b9\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u95ed\u5305\u5728\u9ad8\u9636\u51fd\u6570\u4e2d\u7684\u89d2\u8272<\/h3>\n<\/p>\n<p><p><strong>\u95ed\u5305\u80fd\u591f\u521b\u5efa\u9ad8\u9636\u51fd\u6570\uff0c\u5373\u51fd\u6570\u53ef\u4ee5\u63a5\u6536\u53e6\u4e00\u4e2a\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570\u6216\u8fd4\u56de\u4e00\u4e2a\u51fd\u6570<\/strong>\u3002\u8fd9\u589e\u52a0\u4e86PHP\u7f16\u7a0b\u7684\u62bd\u8c61\u5c42\u6b21\u3002\u5217\u5982\uff0c\u4e00\u4e2a\u95ed\u5305\u53ef\u4ee5\u8fd4\u56de\u53e6\u4e00\u4e2a\u95ed\u5305\uff0c\u4f9d\u6b64\u6765\u6784\u5efa\u590d\u6742\u7684\u5904\u7406\u6d41\u7a0b\u6216\u5b9e\u73b0\u67d0\u79cd\u7279\u5b9a\u7684\u529f\u80fd\u903b\u8f91\u3002<\/p>\n<\/p>\n<p><p>\u5728\u6784\u5efa\u62bd\u8c61\u5c42\u548c\u5b9e\u73b0\u63a7\u5236\u53cd\u8f6c\uff08IOC\uff09\u7b49\u8bbe\u8ba1\u6a21\u5f0f\u4e2d\uff0c\u95ed\u5305\u63d0\u4f9b\u4e86\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684\u6784\u5efa\u5757\u3002\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u5927\u5e45\u5ea6\u63d0\u9ad8\u4ee3\u7801\u7684\u590d\u7528\u6027\u548c\u7075\u6d3b\u6027\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u95ed\u5305\u5728\u8bbe\u8ba1\u6a21\u5f0f\u4e2d\u7684\u8fd0\u7528<\/h3>\n<\/p>\n<p><p>\u95ed\u5305\u7684\u4f7f\u7528\u8fdc\u8fdc\u8d85\u51fa\u4e86\u7b80\u5355\u7684\u529f\u80fd\u5c01\u88c5\uff0c\u5b83\u5728\u73b0\u4ee3PHP\u5f00\u53d1\u4e2d\uff0c\u4e5f\u662f\u5b9e\u73b0\u5404\u79cd\u8bbe\u8ba1\u6a21\u5f0f\u7684\u5173\u952e\u6784\u5efa\u5757\u3002<strong>\u5c24\u5176\u5728\u4f9d\u8d56\u6ce8\u5165\u548c\u4e2d\u95f4\u4ef6\u8bbe\u8ba1\u6a21\u5f0f\u4e2d\uff0c\u95ed\u5305\u8d77\u5230\u4e86\u627f\u4e0a\u542f\u4e0b\u7684\u4f5c\u7528<\/strong>\u3002<\/p>\n<\/p>\n<p><p>\u8bbe\u8ba1\u6a21\u5f0f\u5982\u4e2d\u95f4\u4ef6\uff0c\u53ef\u4ee5\u5229\u7528\u95ed\u5305\u5c06\u8bf7\u6c42\u5904\u7406\u6d41\u7a0b\u5206\u89e3\u4e3a\u591a\u4e2a\u6613\u4e8e\u7ba1\u7406\u7684\u5355\u5143\u3002\u6bcf\u4e2a\u95ed\u5305\u53ef\u4ee5\u5bf9\u8bf7\u6c42\u8fdb\u884c\u64cd\u4f5c\uff0c\u7136\u540e\u5c06\u5176\u4f20\u9012\u7ed9\u94fe\u4e2d\u7684\u4e0b\u4e00\u4e2a\u95ed\u5305\uff0c\u76f4\u5230\u6700\u540e\u7684\u54cd\u5e94\u88ab\u751f\u6210\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u95ed\u5305\u5728\u72b6\u6001\u4fdd\u6301\u65b9\u9762\u7684\u5e94\u7528<\/h3>\n<\/p>\n<p><p>\u95ed\u5305\u53ef\u4ee5\u6355\u83b7\u5b83\u4eec\u5b9a\u4e49\u65f6\u6240\u5728\u7684\u4f5c\u7528\u57df\u7684\u72b6\u6001\uff0c\u8fd9\u610f\u5473\u7740\u5373\u4f7f\u5728\u5916\u5c42\u51fd\u6570\u5df2\u7ecf\u9000\u51fa\u540e\uff0c<strong>\u95ed\u5305\u4f9d\u7136\u4fdd\u6301\u5bf9\u8fd9\u4e9b\u72b6\u6001\u7684\u8bbf\u95ee\u6743\u9650<\/strong>\u3002\u8fd9\u79cd\u7279\u6027\u53ef\u4ee5\u7528\u6765\u521b\u5efa\u7279\u5b9a\u7684\u72b6\u6001\u751f\u6210\u5668\u6216\u8fed\u4ee3\u5668\u3002<\/p>\n<\/p>\n<p><p>PHP\u4e2d\u7684\u751f\u6210\u5668\uff08generator\uff09\u5c31\u662f\u5229\u7528\u95ed\u5305\u72b6\u6001\u4fdd\u6301\u7684\u4e00\u4e2a\u4f8b\u5b50\u3002\u901a\u8fc7\u4fdd\u6301\u5f53\u524d\u4ea7\u751f\u7684\u72b6\u6001\uff0c\u95ed\u5305\u53ef\u4ee5\u5728\u6bcf\u6b21\u8c03\u7528\u65f6\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u503c\uff0c\u76f4\u5230\u6ee1\u8db3\u67d0\u79cd\u6761\u4ef6\u540e\u505c\u6b62\u3002<\/p>\n<\/p>\n<p><p>\u603b\u7ed3\u6765\u8bf4\uff0c\u95ed\u5305\u5728PHP\u4e2d\u626e\u6f14\u7740\u591a\u79cd\u89d2\u8272\uff0c\u4ece\u7b80\u5355\u7684\u529f\u80fd\u5c01\u88c5\u5230\u590d\u6742\u7684\u8bbe\u8ba1\u6a21\u5f0f\u5e94\u7528\uff0c\u95ed\u5305\u7684\u7075\u6d3b\u6027\u548c\u5f3a\u5927\u80fd\u529b\u4f7f\u5f97\u5b83\u6210\u4e3a\u73b0\u4ee3PHP\u7f16\u7a0b\u4e0d\u53ef\u6216\u7f3a\u7684\u5de5\u5177\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>\u4ec0\u4e48\u662fPHP\u4e2d\u7684\u95ed\u5305\uff1f<\/strong><br \/>\n\u95ed\u5305\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u533f\u540d\u51fd\u6570\uff0c\u5728PHP\u4e2d\uff0c\u95ed\u5305\u53ef\u4ee5\u8bbf\u95ee\u5b9a\u4e49\u5b83\u7684\u51fd\u6570\u4f5c\u7528\u57df\u4e2d\u7684\u53d8\u91cf\u3002\u95ed\u5305\u901a\u5e38\u5728\u5c06\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9\u5176\u4ed6\u51fd\u6570\u65f6\u4f7f\u7528\uff0c\u6216\u8005\u4f5c\u4e3a\u8fd4\u56de\u503c\u8fd4\u56de\u7ed9\u5176\u4ed6\u51fd\u6570\u3002<\/p>\n<p><strong>\u95ed\u5305\u5728PHP\u4e2d\u6709\u4ec0\u4e48\u7528\u5904\uff1f<\/strong><br \/>\n\u95ed\u5305\u5728PHP\u4e2d\u6709\u591a\u79cd\u7528\u9014\uff0c\u4e0b\u9762\u5217\u4e3e\u51e0\u4e2a\u5e38\u89c1\u7684\u7528\u9014\uff1a<\/p>\n<ol>\n<li><strong>\u56de\u8c03\u51fd\u6570\uff1a<\/strong> \u95ed\u5305\u53ef\u4ee5\u4f5c\u4e3a\u56de\u8c03\u51fd\u6570\u4f20\u9012\u7ed9\u5176\u4ed6\u51fd\u6570\uff0c\u5f53\u67d0\u4e2a\u4e8b\u4ef6\u89e6\u53d1\u65f6\uff0c\u56de\u8c03\u51fd\u6570\u4f1a\u88ab\u6267\u884c\u3002<\/li>\n<li><strong>\u521b\u5efa\u5bf9\u8c61\uff1a<\/strong> \u901a\u8fc7\u4f7f\u7528\u95ed\u5305\uff0c\u53ef\u4ee5\u5728\u533f\u540d\u51fd\u6570\u5185\u90e8\u521b\u5efa\u548c\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u5bf9\u8c61\u3002\u8fd9\u5728\u4e00\u4e9b\u7279\u6b8a\u7684\u60c5\u51b5\u4e0b\u5f88\u6709\u7528\uff0c\u4f8b\u5982\u5728\u5355\u4f8b\u6a21\u5f0f\u4e2d\uff0c\u4f7f\u7528\u95ed\u5305\u80fd\u591f\u786e\u4fdd\u53ea\u6709\u4e00\u4e2a\u5b9e\u4f8b\u88ab\u521b\u5efa\u3002<\/li>\n<li><strong>\u5ef6\u8fdf\u6267\u884c\uff1a<\/strong> \u4f7f\u7528\u95ed\u5305\u53ef\u4ee5\u5ef6\u8fdf\u6267\u884c\u67d0\u4e2a\u51fd\u6570\u6216\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5728\u7279\u5b9a\u7684\u6761\u4ef6\u4e0b\u89e6\u53d1\u95ed\u5305\u7684\u6267\u884c\u3002<\/li>\n<li><strong>\u5c01\u88c5\u79c1\u6709\u72b6\u6001\uff1a<\/strong> \u95ed\u5305\u53ef\u4ee5\u5c01\u88c5\u79c1\u6709\u72b6\u6001\uff0c\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e9b\u53ea\u6709\u95ed\u5305\u5185\u90e8\u53ef\u4ee5\u8bbf\u95ee\u7684\u53d8\u91cf\uff0c\u5e76\u5bf9\u5916\u90e8\u4e0d\u53ef\u89c1\u3002<\/li>\n<\/ol>\n<p><strong>\u5982\u4f55\u5728PHP\u4e2d\u4f7f\u7528\u95ed\u5305\uff1f<\/strong><br \/>\n\u5728PHP\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>function()<\/code>\u5173\u952e\u5b57\u6765\u521b\u5efa\u95ed\u5305\u3002\u5e38\u89c1\u7684\u521b\u5efa\u95ed\u5305\u7684\u65b9\u6cd5\u662f\u4f7f\u7528\u533f\u540d\u51fd\u6570\uff0c\u4f8b\u5982 <code>$closure = function() { return &quot;Hello, World!&quot;; };<\/code>\uff0c\u7136\u540e\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528<code>$closure()<\/code>\u6765\u6267\u884c\u95ed\u5305\u3002\u95ed\u5305\u7684\u8bed\u6cd5\u4e0e\u666e\u901a\u7684\u51fd\u6570\u7c7b\u4f3c\uff0c\u53ef\u4ee5\u63a5\u53d7\u53c2\u6570\uff0c\u5e76\u8fd4\u56de\u503c\u3002\u53ef\u4ee5\u4f7f\u7528<code>use<\/code>\u5173\u952e\u5b57\u6765\u5f15\u5165\u5916\u90e8\u53d8\u91cf\u5230\u95ed\u5305\u4e2d\uff0c\u4f8b\u5982 <code>$closure = function($name) use ($var) { return &quot;Hello, $name! $var&quot;; };<\/code>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u95ed\u5305\u5728PHP\u4e2d\u4e3b\u8981\u7528\u4e8e \u5305\u88c5\u7279\u5b9a\u7684\u529f\u80fd\u4ee3\u7801\u5757\uff0c\u4ee5\u4fbf\u5b83\u4eec\u53ef\u4ee5\u5728\u4e00\u4e2a\u53d8\u91cf\u4e2d\u4f20\u9012\u548c\u4f7f\u7528\u3001\u4e3a\u51fd\u6570\u521b\u5efa\u4e00\u4e2a\u7279\u5b9a\u7684\u4f5c\u7528\u57df\u6216 [&hellip;]","protected":false},"author":3,"featured_media":182913,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/182893"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=182893"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/182893\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/182913"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=182893"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=182893"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=182893"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}