我正在学习我的方式来应用一些分离关注。我在localhost / admin / index.php。
我的index.php如下
...
$admin = new Admin();
if($_SESSION["user_privilege"]!=100) {
header("Location: error.php");
exit;
}
else
include('views/admin_panel.php');
' admin_panel.php'
!DOCTYPE html>
<html>
<head>
<title> Admin Panel </title>
</head>
<body>
<?php
/** Create an array of admin features with the key being the get url
* and the value being the feature
*/
$tasks = array('user_accounts'=> 'User account Management','products' => 'Product management','categories' => 'Category Management','static_pages'=>'Page creation and deletion', 'customer_query'=> 'Answer Queries from users');
echo '<ul>';
foreach($tasks as $key => $val) {
echo '<li><a href="index.php?'.$key.'">'.$val.'</a></li>';
}
echo '</ul>';
?>
</body>
</html>
那个简单的东西。现在,如果我有一个GET请求,例如index.php?user_accounts,并且我在&views; /__accounts.php&#39;中有该模板,我已将以下行添加到index.php < / p>
if ($admin->clickAction("user_accounts") == true)
include('views/user_accounts.php');
#The functions are defined in the model
但是,这是正确的方法吗?我想不是,因为之前包含的admin_panel也出现了user_accounts模板,这不是我所希望的。