{"id":49074,"date":"2024-12-02T08:43:02","date_gmt":"2024-12-02T00:43:02","guid":{"rendered":"https:\/\/fwq.ai\/blog\/49074\/"},"modified":"2024-12-02T08:43:02","modified_gmt":"2024-12-02T00:43:02","slug":"%e5%a6%82%e4%bd%95%e5%b0%86-php-%e4%ba%8c%e7%bb%b4%e6%95%b0%e7%bb%84%e8%bd%ac%e6%8d%a2%e4%b8%ba-json-%e6%a0%bc%e5%bc%8f%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/49074\/","title":{"rendered":"\u5982\u4f55\u5c06 PHP \u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a JSON \u683c\u5f0f\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5982\u4f55\u5c06 PHP \u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a JSON \u683c\u5f0f\uff1f<\/h1>\n<p>\u4eca\u65e5\u4e0d\u80af\u57cb\u5934\uff0c\u660e\u65e5\u4f55\u4ee5\u62ac\u5934\uff01\u6bcf\u65e5\u4e00\u53e5\u52aa\u529b\u81ea\u5df1\u7684\u8bdd\u54c8\u54c8~\u54c8\u55bd\uff0c\u4eca\u5929\u6211\u5c06\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u7bc7<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5982\u4f55\u5c06 PHP \u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a JSON \u683c\u5f0f\uff1f\u300b<\/span>\uff0c\u4e3b\u8981\u5185\u5bb9\u662f\u8bb2\u89e3<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\uff0c\u611f\u5174\u8da3\u7684\u670b\u53cb\u53ef\u4ee5\u6536\u85cf\u6216\u8005\u6709\u66f4\u597d\u7684\u5efa\u8bae\u5728\u8bc4\u8bba\u63d0\u51fa\uff0c\u6211\u90fd\u4f1a\u8ba4\u771f\u770b\u7684\uff01\u5927\u5bb6\u4e00\u8d77\u8fdb\u6b65\uff0c\u4e00\u8d77\u5b66\u4e60\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241108\/1731057895672dd8e7af21a.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5c06 PHP \u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a JSON \u683c\u5f0f\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u5c06 PHP \u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a JSON \u683c\u5f0f\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>php \u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a json<\/strong><\/p>\n<p>\u60a8\u6709\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>$array = [\n    'data' =&gt; [\n        'colid' =&gt; 2,\n        'colcode' =&gt; 02,\n        'colname' =&gt; '\u7535\u5b50\u4fe1\u606f\u4e0e\u63a7\u5236\u5de5\u7a0b\u5b66\u9662',\n        'orgidentify' =&gt; 'fafu',\n        'isdelete' =&gt; 0\n    ],\n    'code' =&gt; 0\n];<\/pre>\n<p>\u60a8\u5c1d\u8bd5\u4f7f\u7528 json_encode \u5c06\u8be5\u6570\u7ec4\u8f6c\u6362\u4e3a json\uff0c\u4f46\u6ca1\u6709\u5f97\u5230\u4efb\u4f55\u8f93\u51fa\u3002<\/p>\n<p>\u8fd9\u662f\u56e0\u4e3a json_encode \u51fd\u6570\u53ea\u80fd\u5904\u7406\u4e00\u7ef4\u6570\u7ec4\u6216\u5bf9\u8c61\u3002\u8981\u5c06\u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a json\uff0c\u60a8\u9700\u8981\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<pre>$str = json_encode($array);\necho $str;<\/pre>\n<p>\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<pre>{\n    \"data\": {\n        \"ColID\": 2,\n        \"ColCode\": 02,\n        \"ColName\": \"\u7535\u5b50\u4fe1\u606f\u4e0e\u63a7\u5236\u5de5\u7a0b\u5b66\u9662\",\n        \"OrgIdentify\": \"fafu\",\n        \"IsDelete\": 0\n    },\n    \"code\": 0\n}<\/pre>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300a\u5982\u4f55\u5c06 PHP \u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a JSON \u683c\u5f0f\uff1f\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u7c73\u4e91\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5c06 PHP \u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a JSON \u683c\u5f0f\uff1f \u4eca\u65e5\u4e0d\u80af\u57cb\u5934\uff0c\u660e\u65e5\u4f55\u4ee5\u62ac\u5934\uff01\u6bcf\u65e5\u4e00\u53e5\u52aa\u529b\u81ea\u5df1\u7684\u8bdd\u54c8\u54c8~\u54c8\u55bd\uff0c\u4eca\u5929\u6211\u5c06\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u7bc7\u300a\u5982\u4f55\u5c06 PHP \u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a JSON \u683c\u5f0f\uff1f\u300b\uff0c\u4e3b\u8981\u5185\u5bb9\u662f\u8bb2\u89e3\u7b49\u7b49\uff0c\u611f\u5174\u8da3\u7684\u670b\u53cb\u53ef\u4ee5\u6536\u85cf\u6216\u8005\u6709\u66f4\u597d\u7684\u5efa\u8bae\u5728\u8bc4\u8bba\u63d0\u51fa\uff0c\u6211\u90fd\u4f1a\u8ba4\u771f\u770b\u7684\uff01\u5927\u5bb6\u4e00\u8d77\u8fdb\u6b65\uff0c\u4e00\u8d77\u5b66\u4e60\uff01 php \u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a json \u60a8\u6709\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\uff0c\u5982\u4e0b\u6240\u793a\uff1a $array = [ &#8216;data&#8217; =&gt; [ &#8216;colid&#8217; =&gt; 2, &#8216;colcode&#8217; =&gt; 02, &#8216;colname&#8217; =&gt; &#8216;\u7535\u5b50\u4fe1\u606f\u4e0e\u63a7\u5236\u5de5\u7a0b\u5b66\u9662&#8217;, &#8216;orgidentify&#8217; =&gt; &#8216;fafu&#8217;, &#8216;isdelete&#8217; =&gt; 0 ], &#8216;code&#8217; =&gt; 0 ]; \u60a8\u5c1d\u8bd5\u4f7f\u7528 json_encode \u5c06\u8be5\u6570\u7ec4\u8f6c\u6362\u4e3a json\uff0c\u4f46\u6ca1\u6709\u5f97\u5230\u4efb\u4f55\u8f93\u51fa\u3002 \u8fd9\u662f\u56e0\u4e3a json_encode \u51fd\u6570\u53ea\u80fd\u5904\u7406\u4e00\u7ef4\u6570\u7ec4\u6216\u5bf9\u8c61\u3002\u8981\u5c06\u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a json\uff0c\u60a8\u9700\u8981\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a $str = json_encode($array); echo $str; \u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a { [&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-49074","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49074","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=49074"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49074\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=49074"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=49074"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=49074"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}