Home > Article > Backend Development > php json docking app interface php array to json php json decode php json solution
<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); }); });
The above introduces the php json docking app interface, including json and php content. I hope it will be helpful to friends who are interested in PHP tutorials.