3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Model { public $string; public function __construct() { $this->string = 'MVC + PHP = Awesome!'; } } class View { private $model; private $controller; public function __construct($controller,$model) { $this->controller = $controller; $this->model = $model; } public function output() { return '<p><a href="?action=clicked"'.$this->model->string.'</a></p>'; } } class Controller { private $model; public function __construct($model){ $this->model = $model; } public function clicked() { $this->model->string = 'Updated String!'; } } $model = new Model(); $controller = new Controller($model); $view = new View($controller, $model); if(isset($_GET['action']) && !empty($_GET['action'])) { $controller->{$_GET['action']}(); } echo $view->output(); ?>
Output for 5.0.0 - 7.1.0
<p><a href="?action=clicked"MVC + PHP = Awesome!</a></p>
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/3lvWL on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/3lvWL on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/3lvWL on line 4
Process exited with code 255.