首頁  >  文章  >  後端開發  >  php json對接app介面 php array to json php json decode php json 解

php json對接app介面 php array to json php json decode php json 解

WBOY
WBOY原創
2016-07-29 08:53:001078瀏覽

<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教程有興趣的朋友有幫助。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn