How does php print the original json returned from the server? I used a php request from the server. the server returned the json in the standard format and assigned a value to $ a. What should I do if I want to print the original json data? Echo only displays one Array, print, prinf is empty, and print_r is displayed, but it is not j's advice. how does php print the original json returned from the server?
I used a php request from the server. the server returned the json in the standard format and assigned a value to $ a. What should I do if I want to print the original json data?
Echo only displays one Array, print, prinf is empty, and print_r is displayed, but it is no longer in json format.
------ Solution --------------------
Obviously, $ a is not a json string, but an array of PHP after json_encode.
Correspondingly, you can echo json_decode ($ );
------ Solution --------------------
Echo json_encode ($ a); you can, $ a is obviously a decode string ......
------ Solution --------------------
You have used the Sina SDK, and the function of the SDK is convenient for development. Although the returned format of/statuses/home timeline is json, it is still processed by the SDK.
PHP cannot directly manipulate json strings. Therefore, this SDK helps you convert json into PHP arrays in advance.
------ 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 --------------------
Is it okay to use ajax asynchronously and directly? it supports json well.
Discussion
Thank you very much for providing another solution, but I use the frontend html + js asynchronous processing method, so it is very useful but not usable. Learning! Reference:
PHP code
$ Ch = curl_init ();
$ Ch = curl_init ($ url );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true );
Curl_setopt ($ ch, CU ......