Home  >  Article  >  Backend Development  >  Getting Started with PHP 4 Parsing json objects

Getting Started with PHP 4 Parsing json objects

WBOY
WBOYOriginal
2016-07-28 08:27:56994browse

<code><span><span>function</span><span>logging</span><span>()</span>
    {</span><span>var</span>  x = <span>new</span> XMLHttpRequest();

                x.onreadystatechange =<span><span>function</span><span>()</span>
                {</span><span>if</span>(x.readyState == <span>4</span>) {

                        <span>if</span>(x.status == <span>200</span>) {
                            console.log(<span>"The server replied with: "</span> + x.responseText);
                            txt.text = x.responseText;

                        }


                    }
                };
                <span>var</span> xxx = <span>new</span><span>Object</span>;
                xxx.id=<span>289672082</span>;
                xxx.pwd = <span>'12345'</span>;
                <span>var</span> pcode=  <span>JSON</span>.stringify(xxx);
                x.open(<span>"GET"</span>,<span>"http://localhost/mycode/Test/index.php?code="</span>+pcode);
                x.send(<span>null</span>);
    }</code>

Parse

<code><span>$pcode</span> = <span>$_GET</span>[<span>'code'</span>]; 
<span>$obj</span> = json_decode(<span>$pcode</span>);
<span>echo</span><span>$obj</span>->id . <span>","</span> . <span>$obj</span>-><span>pwd</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 PHP entry 4 parsing json objects, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn