webCOMAND

router::view()

Load and process a view file from the views folder.

Prototype

mixed view(string $name, array $vars = [], boolean $return = FALSE)

Parameters

  • name - Name of the view, including slash-separated subdirectories within the view folder.  The name does not include the ".php".
  • vars - Optional associative array of variables to make available to the view.
  • return - If FALSE (default), echo the view output to the browser.  If TRUE, return the view output as a string.

Return

TRUE is always returned if the return parameter is FALSE or omitted.  Otherwise, the output from the view is returned as a string.

Example

$router = new \io_comand_mvc\router(['exit'=>FALSE]);
if(!$router->route_request()) {
    $router->view('error_page');
}