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.
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.