The json return value includes the function name. how can I call back in PHP?

Source: Internet
Author: User
The json return value includes the function name. how does one perform callback in PHP? This post was finally crawled by zlbpolly at 2014-08-2621: 22: 37. now I can only cut the string and filter out the function name, then the value is in json format. Is there a way to directly call back the function? Jsonp3 ({& nbsp; status: & nbsp; 200, & nbsp json return value with function name, how to call back in PHP?

This post was last edited by zlbpolly at 21:22:37

The following content is captured. now I can only take a string, filter out the function name, and then take the value in json format.
Is there a way to directly call back the function?

Jsonp3 ({"status": 200, "ercode": 0 });

------ Solution --------------------
No good way, because php does not support writing objects {}
I don't know how you filtered out the function name.
Php5.4 and below can be written
$ S = 'jsonp3 ({"status": 200, "ercode": 0 })';
Preg_replace ('/^ \ w +? \ (. +) \) $/Ise ', 'Count ($ r = json_decode ("$1")', $ s );
Print_r ($ r );
Php5.3 and above can be written
$ S = 'jsonp3 ({"status": 200, "ercode": 0 })';
Preg_replace_callback ('/^ \ w +? \((. +) \) $/Is ', function ($ m) use (& $ r) {$ r = json_decode ($ m [1]) ;}, $ s );
Print_r ($ r );

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.