Two different strings, using "= =" After comparison, PHP think is equal, it's strange, how to deal with
Source: Internet
Author: User
Two different strings, using "= =" After comparison, PHP think is equal, good strange
if ("0e1683" = = "0e0473") {
echo "equal";
}
The comparison between "0e0983" and "0e0473" will also be equal, which is why?
------Solution--------------------
You have a very special formula, you have to use a surrogate type of comparison.
if ("0e1683" = = = "0e0473")
The reason is this:
PHP automatically converts data types when compared, making the data types on both sides of an expression consistent. This and plain? Different things are not comparable.
Like a blank sheet of paper and a bill, you can't compare it.
PHP observes that both 0e1683 and 0e0473 are numbers of scientific notation, so they are compared by numerical values.
and 0e1683 means 0 times 10 of 1683, and the result is 0 (0 times any number is 0)
0e0473 is 0, too.
0 = = 0
The expression is set up
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