我有一堂课...
class bootstrap {
public static function redirect($ctrl = false, $act = false, $a = false)
{
echo 'Entered redirect ...';
$url = array('home');
if (!empty($_GET['url'])) {
$url = rtrim($_GET['url'], '/');
$url = explode('/', $url);
print_r($url);
}
$controllerName = 'home';
if (!$ctrl) {
if (isset($url[0])) {
$controllerName = $url[0];
}
}
else {
$controllerName = $ctrl;
}
echo '<br/>Controller: $controllerName';
$file = './controllers/' . $controllerName . '.php';
if (file_exists($file)) {
require_once $file;
}
else {
return false;
}
$controller = new $controllerName;
$action = 'Index';
if (!$act) {
if (isset($url[1])) {
$action = $url[1];
}
}
else {
$action = $act;
}
echo '<br/>Action: $action';
$arg = false;
if (!$a) {
if (isset($url[2])) {
$arg = $url[2];
}
}
else {
$arg = $a;
}
if (!$arg) {
$controller->{$action}();
}
else {
$controller->{$action}($arg);
}
}
}
从index.php
我试图调用这样的redirect
函数......
include './core/init.php';
echo 'Calling redirect ...';
bootstrap::redirect();
现在,我echo 'Calling redirect ...';
在页面上得到了 ,但我从来没有得到 ,echo 'Entered redirect ...';
所以看起来它永远不会进入function
.
希望有人可以帮助我...根据我在手册中阅读的内容,我认为我的课程设置正确。