3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php namespace Temple\Modules\Content\Controllers; class Controller { /* private $request; public function __construct(Request $request = null) { $this->request = $request; } protected function getRequest() { return $this->request; } */ protected function render($file) { if (strpos($file, ':') !== false) { list($module, $file) = explode(':', $file); if ($module == 'CoreApp') { $path = CORE_APP_PATH; } else { $path = MODULES_PATH . '/' . $module; } } else { $module = preg_replace('#\\\?Temple\\\Modules\\\([^\\\]+)\\\.*#', '\1', get_called_class()); $path = MODULES_PATH . '/' . $module; } $path = str_replace('\\', DIRECTORY_SEPARATOR, $path); $path .= '/Views/'; $exp = explode('.', $file); $engine = array_pop($exp); $type = array_pop($exp); echo $path . $file; echo "\n"; } } class PagesController extends Controller { public function indexAction() { //return new Response('Ciao! :)'); } public function showAction($id) { // $page = Page::find($id); // // echo $page->category->route->url; $this->render('show.html.twig'); $this->render('admin/new.html.twig'); $this->render('CoreApp:path/to/file.html.twig'); $this->render('Module:path/to/file.html.twig'); $this->render('file.js.twig'); $this->render('file.json.twig'); $this->render('file.css.twig'); $this->render('file.xml.twig'); } } $x = new PagesController(); $x->showAction(4);
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Notice: Use of undefined constant MODULES_PATH - assumed 'MODULES_PATH' in /in/Du8FZ on line 32 MODULES_PATH/Content/Views/show.html.twig Notice: Use of undefined constant MODULES_PATH - assumed 'MODULES_PATH' in /in/Du8FZ on line 32 MODULES_PATH/Content/Views/admin/new.html.twig Notice: Use of undefined constant CORE_APP_PATH - assumed 'CORE_APP_PATH' in /in/Du8FZ on line 25 CORE_APP_PATH/Views/path/to/file.html.twig Notice: Use of undefined constant MODULES_PATH - assumed 'MODULES_PATH' in /in/Du8FZ on line 27 MODULES_PATH/Module/Views/path/to/file.html.twig Notice: Use of undefined constant MODULES_PATH - assumed 'MODULES_PATH' in /in/Du8FZ on line 32 MODULES_PATH/Content/Views/file.js.twig Notice: Use of undefined constant MODULES_PATH - assumed 'MODULES_PATH' in /in/Du8FZ on line 32 MODULES_PATH/Content/Views/file.json.twig Notice: Use of undefined constant MODULES_PATH - assumed 'MODULES_PATH' in /in/Du8FZ on line 32 MODULES_PATH/Content/Views/file.css.twig Notice: Use of undefined constant MODULES_PATH - assumed 'MODULES_PATH' in /in/Du8FZ on line 32 MODULES_PATH/Content/Views/file.xml.twig
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_STRING in /in/Du8FZ on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_STRING in /in/Du8FZ on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/Du8FZ on line 2
Process exited with code 255.