Home  >  Article  >  Backend Development  >  php handles json and xml

php handles json and xml

WBOY
WBOYOriginal
2016-07-29 09:15:271034browse

json transcoding

<code>json_encode(<span>$mixed</span>);</code>

json decoded into original data

<code>json_decode(<span>$json</span>,[ture]);<span>//ture</span> 表示解析成数组</code>

Judge whether the data is legal json string

<code><span><span>function</span><span>is_json</span><span>(<span>$string</span>)</span> {</span>
 json_decode(<span>$string</span>);
 <span>return</span> (json_last_error() == JSON_ERROR_NONE);
}</code>

Copyright statement: Knowledge comes from the people, and is used by the people! Reprinting is welcome. Please attach a link to this article at the beginning. The article will be updated from time to time!

The above introduces how to process json and xml in PHP, including the relevant 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