Differences between three equal signs (=) and two equal signs (=) in php

Source: Internet
Author: User
The following is a detailed analysis of the differences between the three equal signs () and the two equal signs () in php. For more information, see

The following is a detailed analysis of the differences between the three equal signs (=) and the two equal signs (=) in php. For more information, see

First, give a column:
For example, a function returns the following results:
1. number greater than 0
2. Number smaller than 0
3. number equal to 0 (that is, 0)
4. False (upon failure)
In this case, if you want to capture the failure, you must use = instead of =
Because = matches 4th cases and 3rd cases, because 0 is false!

The three equal signs indicate that the types of comparison objects must be consistent. The two equal signs indicate that the conditions are met as long as the values are equal.

Let's add:
$ A = '2'; // balanced type 2
$ B = 2; // numeric type 2
$ A = $ B, yes, Hong Kong servers, both 2
$ A = $ B. It is incorrect. For an American server, because $ a is a numeric type, $ B is a numeric type, and the VM has the same value but different types.
There is also the "0" that "linvo1986-" said.

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.