PHP Development Experience Four

Source: Internet
Author: User
Tags php json

1,php JSON data returned to an HTML page cannot contain special characters

Some time in PHP to write query database data, in JSON format to return to the front page JS file, JS file to Angularjs function call processing method for data display, but the data returned to normal, Angularjs's function call came directly into the. Error instead of. Success.

The error message is: undefined. It is unclear where the problem appears.

After debugging, it is found that the JSON data contains a carriage return character, these special characters must be processed. The front end can parse JSON data normally. Therefore, it is normal to call the following function after processing:

$json _string=str_replace(php_eol$json _stringecho$ Json_string

PHP Development Experience Four

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: 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.