[thelist] [php] Using the OR operator in an IF statement
Help Center Live - Mike
mike at helpcenterlive.com
Sat Jan 8 07:48:31 CST 2005
On 8 Jan 2005, at 13:23, Phil Turmel wrote:
> switch ($_POST['usertype']) {
> case "student":
> case "staff":
> case "admin":
> break;
> default:
> // ...
> }
I would also recommend an if function around that switch to make sure
that the POST var has been sent in the first place
if (isset($_POST['usertype'])) {
switch ($_POST['usertype']) {
case "student":
case "staff":
case "admin":
break;
default:
// ...
}
}
.. or ..
if (isset($_POST['usertype']) !== 'student' &&
isset($_POST['usertype']) !== 'staff' && isset($_POST['usertype']) !==
'admin') {
// ...
}
Mike
More information about the thelist
mailing list