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

PHP_02 usage supplement

WBOY
WBOYOriginal
2016-11-16 10:24:051250browse

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;

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