谁想要知道我落得这样做,最终的代码如下......(这是从我的router.class.php)
$route = (empty($_GET['rt'])) ? '' : $_GET['rt'];
$this->route = explode('/', $route);
/*** a new controller class instance ***/
$class = $this->controller . 'Controller';
$controller = new $class($this->registry);
/*** load arguments for action ***/
$arguments = array();
foreach ($this->route as $key => $val)
{
if ($key == 0 || $key == 1)
{
}
else
{
$arguments[$key] = $val;
}
}
/*** execute controller action w/ parameters ***/
call_user_func_array(array($controller, $action), $arguments);
?>
如果我的网址是
http://mysite.com/documentation/article/3
我的控制器看起来像这样...
Class documentationController Extends baseController
{
public function article($article_ID = '')
{
echo $article_ID; //shows 3
}
}
?>
感谢您的帮助。