The length of the string received by ajax is different.

Source: Internet
Author: User
The length of the string received by ajax is not the same. I use ajax to pass a parameter, and then php receives it and prints it with var_dump. the length is 41. then I copy the same string to php, print the var_dump directly. the length is 42. as follows: string (41) & quot; & lt; pclass = & quot; xg1 & quot; & g ajax receives different string lengths
I used ajax to pass a parameter, and php received it, and printed it with var_dump. the length is 41. then I copied the same string to php and printed it with var_dump. the length is 42. as follows:

String (41 )"
[Data]"
String (42 )"
[Data]"

The string is the same and the length is different. I don't know why the difference may occur. considering that the encoding may be different, I tried
Declare the encoding when receiving the message, as shown in figure
Header ("Content-type: text/html; charset = GB2312 ");
The problem is not solved if the string is converted into the same encoding.
What is the most likely cause of this situation?

------ Solution --------------------
This is a difference caused by the operating system.
In the window system, press enter to wrap the line (\ r \ n)
Linux is a line feed (\ n)

Exactly one character difference
------ Solution --------------------
Print_r (unpack ('H * ', $ str ));
Let's take a look!
What is the use of a guess?

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.