Unpredictable characters at the end of PHPfile_get_contents

Source: Internet
Author: User
This afternoon, I found that a program I wrote was suddenly unable to be used for troubleshooting. The cause was that when PHPfile_get_contents was used to obtain JSON format data returned by a url, unexpected characters were added at the end. although the data format displayed on the webpage is normal...

This afternoon I found that a program I wrote was suddenly unavailable. The cause was that when I used PHP file_get_contents to retrieve JSON format data returned by a url, it was inexplicably added with unpredictable content at the end. character
Although the data format displayed on the webpage is normal, it is found that there are several characters at the end of the copy to the editor.

We can see that SOH characters are added to the end ..

Of course, the results returned by capturing the same link with php curl are in normal JSON format.
PS: PHP Version 5.4.12
What is the cause?

Reply content:

This afternoon I found that a program I wrote was suddenly unavailable. The cause was that when I used PHP file_get_contents to retrieve JSON format data returned by a url, it was inexplicably added with unpredictable content at the end. character
Although the data format displayed on the webpage is normal, it is found that there are several characters at the end of the copy to the editor.

We can see that SOH characters are added to the end ..

Of course, the results returned by capturing the same link with php curl are in normal JSON format.
PS: PHP Version 5.4.12
What is the cause?

Ascii control characters.

Refer:

Http://stackoverflow.com/questions/1497885/remove-control-characters-from-php-string

Http://blog.sina.com.cn/s/blog_4d6a2e4301018cx3.html

Ps: You are still using a public account ..

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.