3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 = BookModel::all(); } function show() { $id = 1; $books = BookModel::find(1); } } class Book extend Model{ 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 5.4.0 - 5.4.30
Parse error: syntax error, unexpected 'extend' (T_STRING), expecting '{' in /in/KGoTW on line 64
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_STRING, expecting '{' in /in/KGoTW on line 64
Process exited with code 255.