If语句If字符串的变量不存在.


If statement if variable for string does not exist...?

我该如何编写一个IF语句,说明如果$req不为空并且等于不存在的字符串,则加载load_template(tpl_path.'err404.tpl');,如果$req不匹配或等于有效值,则显示错误页面。

if ($req == '')              load_template(tpl_path.'index.tpl');
if ($req == 'dologin')      include 'includes/dologin.php';

使用切换语句:

switch($req) {
  case '':
    load_template(tpl_path.'index.tpl');
    break;
  case 'dologin':
    include 'includes/dologin.php';
    break;
  default:
    load_template(tpl_path.'err404.tpl');
}