3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class UserData{ public $user; public $userid; public function __construct($username, $userid){ $this->user = $username; $this->userid = $userid; } public function display(){ echo "Username is {$this->user} and user id is{$this->userid}"; } class Admin extends UserData{ } } $user = "mamun"; $id = "25"; $ur = new UserData($user, $id); echo "<br/>"; $ur->display(); echo "<br/>"; $ad = new Admin($user,$id); $ad->display(); ?>
Output for 7.1.0 - 7.1.7
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting function (T_FUNCTION) or const (T_CONST) in /in/WOjNT on line 17
Process exited with code 255.
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.0.20
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting function (T_FUNCTION) in /in/WOjNT on line 17
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught Error: syntax error, unexpected T_CLASS, expecting T_FUNCTION in /in/WOjNT:17 Stack trace: #0 {main}
Process exited with code 255.