Noppy
1
Hi,
so i’ve noticed that sometimes this
if($_GET['order'] !==''){ echo 'do something';}
works and sometimes i have to do it this way
if(!($_GET['order'] =='')){ echo 'do something';}
and move the not operator outside of the equals bit. what is the difference and why does it sometimes work.
thanks
SamA74
2
I don’t really know, but I think maybe that
if(!($_GET['order'] =='')) {}
is the same as
if($_GET['order'] !='') {}
and that
if($_GET['order'] !=='') {}
is the same as
if(!($_GET['order'] ==='')) {}
So it’s the same difference as between ==
and ===
Does that make sense?
1 Like
a !== b
is one operation !(a == b)
is two.
If the $GET index does not exist an error or warning is raised.
I prefer to use isset(…) && then test the value.
Tediously tapped on a tablet 
1 Like
oddz
5
One is strict equality and the other is two loose equality operations. They by no means do the same thing.
1 Like
system
Closed
6
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.