Home > php教程 > php手册 > PHP_02 usage supplement

PHP_02 usage supplement

WBOY
Release: 2016-11-16 10:24:05
Original
1247 people have browsed it

Application of JSON string in the project:
①PHP server sends JSON response data to client JS:
PHP:
$arr=[...];
echo json_encode($arr);
JS:
var obj= JSON.parse(str);
②Client JS sends PHP server JSON response data:
JS:
var arr=[...];
var str=JSON.stringify(arr);
PHP:
$arr =json.decode($_REQUEST['str']);
③{} in JSON is parsed as Object by PHP, and the -> symbol is used to read the object members;

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template