PHP logical operator. Solution Solutions

Source: Internet
Author: User
PHP logic operator ...
There are two problems when judging the file type. The code is as follows:
if ($type!== ' gif ' | | $type!== ' JPEG ' | | $type!== ' png ') {
echo "Format error";
}
else {
Echo $type;
}
Question 1: Not equal, is with!==?
Issue 2: | | It doesn't work, or it's useless to change it. If only one can be judged, the explanation is not equal to the correct.
but | | Why not work, this if in C # but absolutely workable AH.
------Solution--------------------
1 can be expressed in! =, can also be expressed with!==, the specific difference between the mother
2 you mean as long as the type is gif,jpeg,png to judge correctly?
That should be written like this: if ($type!== ' gif ' && $type!== ' jpeg ' && $type!== ' png ')
------Solution--------------------
The!== operator is all equal to the negative usage of ' = = = ', which distinguishes values, data types, capitalization, etc.
Just change to this! =.
------Solution--------------------
Question 1: Not equal, is with!==?
! = is not equal to
!== Not all equal to

Question 2:
------Solution--------------------
It doesn't work, or it's useless to change it.

You need to use and && logic to judge.
  • 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.