3v4l.org

run code in 300+ PHP versions simultaneously
<?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 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.

preferences:
169.72 ms | 1386 KiB | 36 Q