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.
Reply to discussion (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 ')
The!== operator is all equal to the negative usage of ' = = = ', which distinguishes values, data types, capitalization, etc.
Just change to this! =.
Question 1: Not equal, is with!==?
! = is not equal to
!== Not all equal to
Issue 2: | | It doesn't work, or it's useless to change it.
You need to use and && logic to judge.
Sorry, the logic is wrong. I'm sorry to delay your time.
Not equal to:<>,! =,!==
Where!== compare types before comparison
In your context, $type!== ' gif ' | | $type!== ' jpeg ' | | $type!== ' png ' is wrong
This logical expression indicates that the condition is true as long as the $type is not equal to one of GIF, JPEG, and PNG.
Set $type = ' gif ', then he must not be equal to JPEG, nor PNG
C # is also wrong, C # is created by the Martians?
So the expression should be the same as an expression, not an expression
$type!== ' gif ' && $type!== ' jpeg ' && $type!== ' png '