Two-byte bug with PHP output string

Source: Internet
Author: User

Recently, the development of iOS partners told me that the parsing server sent back the character information when a bug occurs.

Obviously using the log output is the string "hello" but the use of length calculation is more than two bytes, such as this is 7.

I heard no reason ah, so check my server output, first start to exclude whether in a certain echo or print time, the output of more than two characters.

But let me check to find out all the wood has this problem, directly from the server echo when judging the length of the output, also did not reproduce the problem.

Really a face, after all, PHP is not so familiar.

Finally, when I was 10 o'clock in the evening, I passed the string back through Python, and found that each returned string was preceded by a "\ r \ n", because the characters in the normal log were automatically wrapped and did not appear, so I didn't think of it at all.

I naturally went to find out how I showed the output "\ r \ n", but when I looked through the script and didn't find the two goods, my heart was a broken O (╯-╰) O.

Finally, the problem is that one of the include PHP scripts has a blank line at the end of the!!!!!

<? PHP Echo "Hello";? >// This empty line will cause you to output "\r\nhello" ...

So you just put a blank line in front of each of my outputs, manual black question mark face!

PHP is the best language in the world!!!!!!

Two-byte bug with PHP output string

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.