{"id":49172,"date":"2024-12-02T13:24:09","date_gmt":"2024-12-02T05:24:09","guid":{"rendered":"https:\/\/fwq.ai\/blog\/49172\/"},"modified":"2024-12-02T13:24:09","modified_gmt":"2024-12-02T05:24:09","slug":"php-%e4%ba%8c%e7%bb%b4%e6%95%b0%e7%bb%84%e5%a6%82%e4%bd%95%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\/49172\/","title":{"rendered":"PHP \u4e8c\u7ef4\u6570\u7ec4\u5982\u4f55\u8f6c\u6362\u4e3a JSON \u683c\u5f0f\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>PHP \u4e8c\u7ef4\u6570\u7ec4\u5982\u4f55\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\">\u300aPHP \u4e8c\u7ef4\u6570\u7ec4\u5982\u4f55\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\/20241114\/173156691467359d42a0d09.jpg\" class=\"aligncenter\" title=\"PHP \u4e8c\u7ef4\u6570\u7ec4\u5982\u4f55\u8f6c\u6362\u4e3a JSON \u683c\u5f0f\uff1f\u63d2\u56fe\" alt=\"PHP \u4e8c\u7ef4\u6570\u7ec4\u5982\u4f55\u8f6c\u6362\u4e3a JSON \u683c\u5f0f\uff1f\u63d2\u56fe\" \/><\/p>\n<h2>php \u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a json \u65f6\u7a7a\u8f93\u51fa<\/h2>\n<p>\u5728 php \u4e2d\uff0c\u5229\u7528 json_encode \u51fd\u6570\u53ef\u5c06\u6570\u636e\u8f6c\u6362\u4e3a json \u683c\u5f0f\u3002\u7136\u800c\uff0c\u5982\u679c\u8981\u8f6c\u6362\u4e8c\u7ef4\u6570\u7ec4\u65f6\u9047\u5230\u6ca1\u6709\u8fd4\u56de\u6570\u636e\u7684\u60c5\u51b5\uff0c\u53ef\u5c1d\u8bd5\u4ee5\u4e0b\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<p>\u8fd9\u4e2a\u95ee\u9898\u53ef\u80fd\u51fa\u73b0\u5728\u5c1d\u8bd5\u76f4\u63a5\u5c06\u4e8c\u7ef4\u6570\u7ec4\u4f5c\u4e3a json_encode \u51fd\u6570\u7684\u53c2\u6570\u65f6\u3002\u8fd9\u662f\u56e0\u4e3a php \u4f1a\u5c06\u4e8c\u7ef4\u6570\u7ec4\u89c6\u4e3a\u4e00\u4e2a\u5bf9\u8c61\uff0c\u9700\u8981\u5148\u5bf9\u5176\u8fdb\u884c\u8f6c\u6362\u3002<\/p>\n<h3>\u6b63\u786e\u7684\u8f6c\u6362\u65b9\u6cd5<\/h3>\n<pre>$Array = array(\n    'data' =&gt; array(\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);\n\n\/\/ \u5c06\u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a JSON\n$str = json_encode($Array);\n\n\/\/ \u8f93\u51fa JSON \u5b57\u7b26\u4e32\necho $str;<\/pre>\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff1a<\/p>\n<ul>\n<li>\u6211\u4eec\u4f7f\u7528 array \u51fd\u6570\u521b\u5efa\u4e00\u4e2a\u4e8c\u7ef4\u5173\u8054\u6570\u7ec4 $array\u3002<\/li>\n<li>\u4f7f\u7528 json_encode \u51fd\u6570\u5c06\u6570\u7ec4\u8f6c\u6362\u4e3a json \u5b57\u7b26\u4e32 $str\u3002<\/li>\n<li>\u6700\u540e\uff0c\u901a\u8fc7 echo \u8bed\u53e5\u8f93\u51fa json \u5b57\u7b26\u4e32\u3002<\/li>\n<\/ul>\n<p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u6cd5\uff0c\u4f60\u53ef\u4ee5\u6210\u529f\u5c06\u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a json \u683c\u5f0f\u5e76\u5f97\u5230\u9884\u671f\u7684\u8f93\u51fa\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u7684\u5168\u90e8\u5185\u5bb9\u4e86\uff0c\u662f\u5426\u6709\u987a\u5229\u5e2e\u52a9\u4f60\u89e3\u51b3\u95ee\u9898\uff1f\u82e5\u662f\u80fd\u7ed9\u4f60\u5e26\u6765\u5b66\u4e60\u4e0a\u7684\u5e2e\u52a9\uff0c\u8bf7\u5927\u5bb6\u591a\u591a\u652f\u6301\u7c73\u4e91\uff01\u66f4\u591a\u5173\u4e8e\u6587\u7ae0\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u4e5f\u53ef\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP \u4e8c\u7ef4\u6570\u7ec4\u5982\u4f55\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\u300aPHP \u4e8c\u7ef4\u6570\u7ec4\u5982\u4f55\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 \u65f6\u7a7a\u8f93\u51fa \u5728 php \u4e2d\uff0c\u5229\u7528 json_encode \u51fd\u6570\u53ef\u5c06\u6570\u636e\u8f6c\u6362\u4e3a json \u683c\u5f0f\u3002\u7136\u800c\uff0c\u5982\u679c\u8981\u8f6c\u6362\u4e8c\u7ef4\u6570\u7ec4\u65f6\u9047\u5230\u6ca1\u6709\u8fd4\u56de\u6570\u636e\u7684\u60c5\u51b5\uff0c\u53ef\u5c1d\u8bd5\u4ee5\u4e0b\u89e3\u51b3\u65b9\u6848\uff1a \u8fd9\u4e2a\u95ee\u9898\u53ef\u80fd\u51fa\u73b0\u5728\u5c1d\u8bd5\u76f4\u63a5\u5c06\u4e8c\u7ef4\u6570\u7ec4\u4f5c\u4e3a json_encode \u51fd\u6570\u7684\u53c2\u6570\u65f6\u3002\u8fd9\u662f\u56e0\u4e3a php \u4f1a\u5c06\u4e8c\u7ef4\u6570\u7ec4\u89c6\u4e3a\u4e00\u4e2a\u5bf9\u8c61\uff0c\u9700\u8981\u5148\u5bf9\u5176\u8fdb\u884c\u8f6c\u6362\u3002 \u6b63\u786e\u7684\u8f6c\u6362\u65b9\u6cd5 $Array = array( &#8216;data&#8217; =&gt; array( &#8216;ColID&#8217; =&gt; 2, &#8216;ColCode&#8217; =&gt; &#8217;02&#8217;, &#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 ); \/\/ \u5c06\u4e8c\u7ef4\u6570\u7ec4\u8f6c\u6362\u4e3a JSON $str [&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-49172","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49172","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=49172"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49172\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=49172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=49172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=49172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}