私はクラスを持っています...
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
。
誰かが私を助けてくれることを願っています...マニュアルで読んだことに基づいて、私のクラスは正しく設定されていると思いました。