I am trying to include different headers to different users. How do I layout my if() conditions? I know this is a basic concept.
if($_SESSION['usertype'] == "1"){
// include admin header
if($_SESSION['usertype'] == "0"])
{
// include normal user header
} else {
// include non logged in header ;
}
}
How about using switch instead?:
switch($_SESSION['usertype']) {
case 1:
// ...
break;
case 0:
// ...
break;
default:
// ...
}
Looks more pleasing, in my opinion, than the if/else
approach:
if ($_SESSION['usertype'] === 1) {
// ...
} elseif ($_SESSION['usertype'] === 0) {
// ...
} else {
// ...
}