我希望在switch语句上为下面的特定菜单栏运行一个通配符。
因此,我有一个动态菜单栏的PHP代码:
switch($location):
case "/":
echo '
<li class="active"><a href="/">' . $name . '</a></li>
<li><a href="/parents">Parents</a></li>
<li><a href="//staugie.net">Church Website</a></li>
<li><a href="/kids">Kids Area</a></li>';
break;
case "/parents/*":
//I want this to display at any page that is a sub of /parents.
//Is this the proper syntax?
break;
endswitch;
这就是我的代码。我希望当某人在父文件夹中的任何子文件夹中时,显示父文件夹。此外,我如何对多个字符串进行case语句测试,例如:
case "/" || "/home.html":
//I want this to display at any page that is a sub of /parents.
//Is this the proper syntax?
break;
没有跳转语句的Case块将"失败"。这意味着您可以让多个语句到达同一代码块:
case "/" :
case "/home.html":
//both case statements fall through to here
break;