VGrabko
@VGrabko
Golang, Php, Js

Что я делаю не так?

Вот мой код.
class router {

    protected $router;
    protected $dispatcher;
    protected $ControllerObj;
    private function Controller($name) {
        if(@!$this->ControllerObj[$name]){
            require '../App/Controllers/' . $name . '.php';
            $this->ControllerObj[$name] = new $name();
        }
        return $this->ControllerObj[$name];
    }

    public function __construct() {
        $this->router = new Hoa\Router\Http();
        $this->dispatcher = new Hoa\Dispatcher\Basic();
    }

    public function get($id, $url, $f) {
        $func = $this->Controller($f[0]);
        //$func->$f[1]('78','87');
        $this->router->get($id, $url, $func->$f[1]);
    }

    public function post($id, $url, $f) {
        $func = $this->Controller($f[0]);
        //$func->$f[1]('78','87');
        $this->router->post($id, $url, $func->$f[1]);
    }

    public function Run() {
        $this->dispatcher->dispatch($this->router);
    }

}


Функцию роутр не обрабатывает и сыпятся ошибки
Notice: Undefined property: index::$TestUrl in /home/lucifer/php/Core/modules/router.php on line 29

Notice: Undefined property: index::$Test in /home/lucifer/php/Core/modules/router.php on line 29


Но если вызвать функцию вручную $func->$f[1]('78','87'); (а не через роутер) то всё ok
  • Вопрос задан
  • 142 просмотра
Пригласить эксперта
Ответы на вопрос 1
copist
@copist
Empower people to give
Notice: Undefined property: index::$TestUrl in /home/lucifer/php/Core/modules/router.php on line 29

Notice: Undefined property: index::$Test in /home/lucifer/php/Core/modules/router.php on line 29

Ошибки в файле router.php. На 29ой строке.

Предположительно в
$this->router->post($id, $url, $func->$f[1]);

Из контекста неясно, что именно в переменных $id, $url, $func, $f
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
16 апр. 2024, в 14:20
500 руб./за проект
16 апр. 2024, в 14:03
5000 руб./за проект
16 апр. 2024, в 13:17
5000 руб./за проект