Rumah > Artikel > pembangunan bahagian belakang > php json对接app接口 php array to json php json decode php json 解
<code> json封装 一, <span>public</span><span><span>function</span><span>json</span><span>(<span>$code</span>=<span>0</span>,<span>$message</span>=<span>''</span>,<span>$data</span>=<span>''</span>)</span> {</span><span>$res</span>=<span>array</span>(<span>'code'</span>=><span>$code</span>,<span>'message'</span>=>urlencode(<span>$message</span>),<span>'data'</span>=><span>$data</span>); <span>return</span> urldecode(json_encode(<span>$res</span>)); } 二, <span><span>function</span><span>json</span><span>(<span>$code</span>, <span>$message</span> = <span>''</span>, <span>$data</span> = array<span>()</span>)</span> {</span><span>if</span>(!is_numeric(<span>$code</span>)) { <span>return</span><span>''</span>; } <span>$result</span> = <span>array</span>( <span>'code'</span> => <span>$code</span>, <span>'message'</span> => <span>$message</span>, <span>'data'</span> => <span>$data</span> ); <span>echo</span> json_encode(<span>$result</span>, JSON_UNESCAPED_UNICODE); <span>exit</span>; }</code>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介绍了php json对接app接口,包括了json,php方面的内容,希望对PHP教程有兴趣的朋友有所帮助。