Excuse me, how does PHP print out the original JSON returned from the server?

Source: Internet
Author: User
Tags php print
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 ...
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.