It is strange that php considers two different strings to be equal after being compared with "= ".

Source: Internet
Author: User
Two different strings. after comparison, php considers them to be equal. it is strange if ("0e1683" = "0e0473 "){
Echo "equal ";
}

The comparison between "0e0983" and "0e0473" is also equal. why?


Reply to discussion (solution)

This statement is very special and can only be used for comparison of generations.
If ("0e1683" = "0e0473 ")

The reason is as follows:
Php automatically converts the data type during the comparison so that the data types on both sides of the expression are consistent. Is this simple? Different things cannot be compared.
For example, a piece of white paper and a bill cannot be compared.
Php observed that 0e1683 and 0e0473 are both numerical values of scientific notation, so they are compared by numerical values.
While 0e1683 represents 0 multiplied by 10 to the power of 1683, and the result is 0 (0 multiplied by any number is 0)
Similarly, 0e0473 is also 0.
0 = 0
The expression is true.

The explanation is clear. thank you!

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.