3v4l.org

run code in 300+ PHP versions simultaneously
<?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 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Fatal error: Uncaught Error: Undefined constant "Temple\Modules\Content\Controllers\MODULES_PATH" in /in/Du8FZ:32 Stack trace: #0 /in/Du8FZ(60): Temple\Modules\Content\Controllers\Controller->render('show.html.twig') #1 /in/Du8FZ(76): Temple\Modules\Content\Controllers\PagesController->showAction(4) #2 {main} thrown in /in/Du8FZ on line 32
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Fatal error: Uncaught Error: Undefined constant "Temple\Modules\Content\Controllers\MODULES_PATH" in /in/Du8FZ:32 Stack trace: #0 /in/Du8FZ(60): Temple\Modules\Content\Controllers\Controller->render('show.html.twig') #1 /in/Du8FZ(76): Temple\Modules\Content\Controllers\PagesController->showAction(4) #2 {main} thrown in /in/Du8FZ on line 32
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33
Warning: Use of undefined constant MODULES_PATH - assumed 'MODULES_PATH' (this will throw an Error in a future version of PHP) in /in/Du8FZ on line 32 MODULES_PATH/Content/Views/show.html.twig Warning: Use of undefined constant MODULES_PATH - assumed 'MODULES_PATH' (this will throw an Error in a future version of PHP) in /in/Du8FZ on line 32 MODULES_PATH/Content/Views/admin/new.html.twig Warning: Use of undefined constant CORE_APP_PATH - assumed 'CORE_APP_PATH' (this will throw an Error in a future version of PHP) in /in/Du8FZ on line 25 CORE_APP_PATH/Views/path/to/file.html.twig Warning: Use of undefined constant MODULES_PATH - assumed 'MODULES_PATH' (this will throw an Error in a future version of PHP) in /in/Du8FZ on line 27 MODULES_PATH/Module/Views/path/to/file.html.twig Warning: Use of undefined constant MODULES_PATH - assumed 'MODULES_PATH' (this will throw an Error in a future version of PHP) in /in/Du8FZ on line 32 MODULES_PATH/Content/Views/file.js.twig Warning: Use of undefined constant MODULES_PATH - assumed 'MODULES_PATH' (this will throw an Error in a future version of PHP) in /in/Du8FZ on line 32 MODULES_PATH/Content/Views/file.json.twig Warning: Use of undefined constant MODULES_PATH - assumed 'MODULES_PATH' (this will throw an Error in a future version of PHP) in /in/Du8FZ on line 32 MODULES_PATH/Content/Views/file.css.twig Warning: Use of undefined constant MODULES_PATH - assumed 'MODULES_PATH' (this will throw an Error in a future version of PHP) in /in/Du8FZ on line 32 MODULES_PATH/Content/Views/file.xml.twig
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20
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.1.6, 5.2.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.3.11, 4.4.0 - 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.

preferences:
219.56 ms | 401 KiB | 314 Q