I have a class …
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);
}
}
}
And from index.php i’m trying to call the redirect function like this …
include './core/init.php';
echo 'Calling redirect ...';
bootstrap::redirect();
Now, I get the echo 'Calling redirect ...'; on the page, but I never get the echo 'Entered redirect ...'; so it appears it’s never getting into the function.
Hopefully somebody can help me … based on what I read in the manual I thought my class was setup right.
Your class bootstrap has to be defined in init.php
Greatings 🙂