// Using a template file to render HTML $view = new \PHPView\View('my_template.php'); $content = $view->render(['title'=>'My website','content'=>'Welcome to my website']); echo $content;
// Using a template string to render HTML $view = new \PHPView\View('In this example, we create a new View object and pass it a template string instead of a file. This is useful when the template is small and not worth creating a file for. The PHP View library provides a simple and easy-to-use way for developers to work with templates in PHP.<?php echo $title; ?> '); $content = $view->render(['title'=>'My website','content'=>'Welcome to my website']); echo $content;