3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Template { private $dir = 'app/views/'; public function render($template, $data = [], $renderNow = true){ ob_start(); extract($data, EXTR_SKIP); require $this->dir.$template.'.html'; $ret = ob_get_clean(); if($renderNow){ echo $ret; } return $ret; } } //in controllers/someController.php class SomeController { public function list(){ $template = new Template(); $template->render('list'); } public function show($id){ $template = new Template(); $template->render('some',['id' => $id]); } } //in frontController //somehow you know you need 'someController' and action - 'show': $someController = new SomeController(); $someController->list(); ?>
Output for git.master, git.master_jit, rfc.property-hooks
Warning: require(): open_basedir restriction in effect. File(app/views/list.html) is not within the allowed path(s): (/tmp:/in:/etc) in /in/TvScq on line 9 Warning: require(app/views/list.html): Failed to open stream: Operation not permitted in /in/TvScq on line 9 Fatal error: Uncaught Error: Failed opening required 'app/views/list.html' (include_path='.:') in /in/TvScq:9 Stack trace: #0 /in/TvScq(25): Template->render('list') #1 /in/TvScq(39): SomeController->list() #2 {main} thrown in /in/TvScq on line 9
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
60.03 ms | 401 KiB | 8 Q