PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
LanceEh
Forum Commoner
Posts: 46 Joined: Tue Feb 17, 2009 11:53 am
Location: Florida
Post
by LanceEh » Sat Mar 14, 2009 4:30 pm
I've tried everything I can think of to get this working.
This seems logical, but doesn't work (only seems to register on the first number being checked)
Code: Select all
if ($var != '12345' || '67890') {
}
Thanks.
panic!
Forum Regular
Posts: 516 Joined: Mon Jul 31, 2006 7:59 am
Location: Brighton, UK
Post
by panic! » Sat Mar 14, 2009 4:32 pm
you need to write
if ($var != '12345' || $var= '67890') {
}
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Sat Mar 14, 2009 4:33 pm
It's counter intuitive, you need to use the AND operator.
Code: Select all
if ($var != '12345' && $var != '67890') {
}
LanceEh
Forum Commoner
Posts: 46 Joined: Tue Feb 17, 2009 11:53 am
Location: Florida
Post
by LanceEh » Sat Mar 14, 2009 4:37 pm
Could of swore I tried one of those, anyways, thanks, I will give it a shot!
Many thanks.
LanceEh
Forum Commoner
Posts: 46 Joined: Tue Feb 17, 2009 11:53 am
Location: Florida
Post
by LanceEh » Sat Mar 14, 2009 4:38 pm
If I'm wanting to do three or more would it be logical to
Code: Select all
if ($var != '12345' && $var != '67890' && $var !='09876')
?
By the way, heck of a fast response.
Thanks.
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Sat Mar 14, 2009 4:40 pm
At that point I would use an array.
Code: Select all
$foo = array(1, 2, 3);
if (!in_array($value, $foo)) {
}