title: Return multiple values in a function in PHP
body: <p>I am looking for a way to return multiple parameters in a function. I am building a routing system for my <a href="https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller" rel="nofollow noreferrer">MVC</a> framework. And currently I am working on a way to get unlimited arguments in a function, based on an HTTP request;</p>
  
  <p>This is the part I am stuck on. Look on the bottom of the code
  $controller->{$route->getMethod()}();</p>
  
  <p>The controller calls a function, and now I need to get a solution to add values in de function. I can do $controller->{$route->getMethod()}($route->getArgs();</p>
  
  <p>But then only the first argument will be set. How can I return more than one argument in that function?</p>
  
  <pre><code>public function dispatchRoute(Route $route)
  {
      if(!file_exists($this-&gt;pathToController . '/' . ucfirst($route-&gt;getController()) . 'Controller.php'))
          throw new \Exception(
          sprintf('Cannot find %sController.php in directory %s', $route-&gt;getController(), $this-&gt;pathToController));
  
      require_once($this-&gt;pathToController . '/' . ucfirst($route-&gt;getController()) . 'Controller.php');
  
      $controller = $route-&gt;getController() . 'Controller';
      $controller = new $controller();
  
      if(!method_exists($controller, $route-&gt;getMethod()))
          throw new \Exception(sprintf('Method %s is not found in %sController', $route-&gt;getMethod(), $route-&gt;getController()));
  
      $dataHandler = new RequestDataHandler();
      $dataHandler-&gt;getRequestArguments();
      $controller-&gt;{$route-&gt;getMethod()}();
  }
  </code></pre>