Z nudów chciałem sobie napisać jakiegoś swojego framework`a. I napotkałem na pierwszy problem przy próbie podania parametrów metody.
Tak więc:
<?php class Bootstrap { private $url; private $moduleName; private $controllerName; private $methodName; private $parameters; public function __construct() { require 'core/Config.php'; } $this->moduleName = $this->url[0]; $this->controllerName = $this->url[1]; $this->methodName = $this->url[2]; require "application/$this->moduleName/controllers/$this->controllerName.php"; } else { require 'core/errors.php'; $error = new Errors(); return false; } $controller = new $this->controllerName; //nie wiem jak ten problem rozwiązać aby przekazać do metody tyle parametrów ile jest wpisanych w adresie? $controller->{$this->methodName}($this->parameters[0], $this->parameters[1], $this->parameters[2]); } else { $controller->{$this->methodName}(); } } } }
Jakies pomysły jak to można rozwiązać?
Ok mam sprawe załatwiło:
call_user_method_array($this->methodName, $controller, $this->parameters);