3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MVCFramework { var $url = ''; function __construct($url) { $this->url = $url; //HTTP_REQUEST URL $this->run(); } function run() { if ($route = Routes::get($this->url)) { list($controller, $action) = route; $controllerObj = new $$controller; $controllerObj->$$action(); //template } else { print_r('404'); } } } class Routes { static $routes = array(); static function add($route, $controller, $action) { self::$routes[] = array($route, $controller.'Controller', $action); } static function getRoutes() { return self::$routes; } } abstract class Model { // connect to DB and etc. } class BooksController { function index() { $books = Book::all(); } function show() { $id = 1; $books = Book::find(1); } } class Book { static function all() { $books = array('Book', 'Book', 'Book'); return $books; } static function find() { $book = 'Book'; return $book; } } class View { } Routes::add('/books', 'Books', 'index'); Routes::add('/books/:id', 'Books', 'show'); $url = '/books'; new MVCFramework($url);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Call to undefined method Routes::get() in /in/aeFkC:15 Stack trace: #0 /in/aeFkC(10): MVCFramework->run() #1 /in/aeFkC(92): MVCFramework->__construct('/books') #2 {main} thrown in /in/aeFkC on line 15
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:
36.54 ms | 401 KiB | 8 Q