Echo or print_r when php develops an api and outputs json data. how can this problem be solved?
Source: Internet
Author: User
Echo or print_r when php develops the api and outputs json data. Suppose $ selectRows is an array and then outputs (that is, when an external call is used) whether it is echo, return, or print_r. Why can't I find it externally? I am echourlencode (json_encode ($ selectRows), and echo or print_r when I output json data through the php development api?
Assume that $ selectRows is an array before output (that is, when an external call is used) echo, return, print_r, and so on. Why can't I find it externally? echo urlencode (json_encode ($ selectRows), $ gc = file_get_contents (http: // domain name/class name/method name/incoming value) but $ gc can be directly output during output, but print_r (urldecode (json_decode ($ selectRows ))) when I print the array, nothing is left.
------ Solution --------------------
$ SelectRows is the output of your array like this: echo urlencode (json_encode ($ selectRows ));
Echo json_decode (urldecode ($ gc) after getting $ gc with file_get_contents ));
That's right.
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.