Ask, how does PHP print out the original JSON returned from the server?
I used a PHP request from the server, the server returned a standard format JSON, and then assigned to $ A, I now want to print the raw JSON data, what to do?
Echo only shows a array,print,prinf is empty, Print_r is displayed, but it is not JSON-formatted data anymore.
------Solution--------------------
It is obvious that $ A does not store the JSON string, but the PHP array after Json_encode ().
Accordingly, you can echo json_decode ($a);
------Solution--------------------
echo Json_encode ($a), $a is obviously decode string ...
------Solution--------------------
You use the Sina SDK, and the SDK is easy to develop. Although the return format of/statuses/home timeline is JSON, it has been processed internally by the SDK.
PHP cannot manipulate JSON strings directly, so this SDK helps you to pre-convert JSON into an array of PHP.
------Solution--------------------
PHP code
$ch = Curl_init (); $ch = Curl_init ($url); curl_setopt ($ch, Curlopt_returntransfer, true); curl_setopt ($ch, Curlopt_binarytransfer, true); curl_setopt ($ch, Curlopt_connecttimeout, 10); $out = curl_exec ($ch); $out = Trim ($out); Curl_close ($ch); $out = Json_decode ($out, true); Var_dump ($out);
------Solution--------------------
Async directly with Ajax No, it's good.
discussion
Thank you very much for your A different solution, but I used the front-end html+js asynchronous processing, so very useful but not used. Study it!
Reference:
PHP code
$ch = Curl_init ();
$ch = Curl_init ($url);
curl_setopt ($ch, Curlopt_returntransfer, true);
curl_setopt ($ch, CU ...