我使用下面的这个例子来询问如何将数组传递给 Switch,而不是像这样将它们全部列出?
也许如果我从数据库中为所有“页面”获取一个数组作为页面。
我认为这种方法不是最优雅的方法。
switch($_GET['page'])
{
case 'home':
include('home.php');
break;
case 'oem-customers':
include('oem-customers.php');
break;
case 'job-shop':
include('job-shop.php');
break;
case 'anodized-magnet-coils':
include('anodized-magnet-coils.php');
break;
case 'design':
include('design.php');
break;
case 'services':
include('services.php');
break;
case 'black-foil':
include('black-foil.php');
break;
case 'contact':
include('contact.php');
break;
case 'order';
include('order.php');
break;
default:
include('home.php');
}