Json_decode
Mixed Json_decode (String $json [, bool $assoc = False [, int $depth = [, int $options = 0]]])
Accept a JSON-formatted string and convert it to a PHP variable
Json_encode
String Json_encode (mixed $value [, int $options = 0])
Returns the JSON form of value values
For example, in the interface_x need to get the data passed in the interface_y, and data contains special characters, you can put these special characters in the interface_y array, and then json_encode into JSON
The formatted string, passed to Interface_x, is json_decode in the interface_x.
$json 2 = Json_decode ($json, true);//echo "Json2:";//var_dump ($json 2);
Interface_y strings containing special characters are processed, stored in arrays, and Json_encode:
$value = ' ~!@#$%^&* () _+-={}: "; <>?/\123456789123 '; $data = Array (" key "= = $value); $json = Json_encode ($data );//echo "JSON:". " \ n ";//var_dump ($json);
Json_decode an array of incoming JSON data in interface_x.
Reference:
http://php.net/manual/zh/function.json-decode.php
http://php.net/manual/zh/function.json-encode.php
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The above describes the use of PHP Json_encode and Json_decode to pass the data containing special characters, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.