3v4l.org

run code in 300+ PHP versions simultaneously
<?php class GameObject { protected $name; protected $description; public function __construct($name, $description) { $this->name = $name; $this->description = $description; } public function display() { echo "\n Name: " . $this->name; echo "\n Description: " . $this->description; } } class Character extends GameObject { private $url; public function __construct($name, $description, $url) { parent::__construct ($name, $description); $this->url = $url; } public function display() { parent::display (); echo "\n Url: " . $this->url; } } class Obstacle extends GameObject { private $movable; private $hittable; public function __construct($name, $description, $movable, $hittable) { parent::__construct ($name, $description); $this->movable = $movable; $this->hittable = $hittable; } public function display() { parent::display (); echo "\n Movable: " . $this->movable; echo "\n Hittable: " . $this->hittable; } } // Creating object array $objects = array(); $objects['Mario'] = new Character( 'Mario', 'A short, pudgy, plumber who resides in the Mushroom Kingdom.', ' https://upload.wikimedia.org/wikipedia/en/9/99/MarioSMBW.png' ); $objects['Luigi'] = new Character( 'Luigi', 'Younger brother of Mario.', 'https://upload.wikimedia.org/wikipedia/en/f/f1/LuigiNSMBW.png' ); $objects['Bowser'] = new Character( 'Bowser', 'Bowser is the leader and most powerful of the turtle-like Koopa race.', 'https://upload.wikimedia.org/wikipedia/en/e/ec/Bowser_-_New_Super_Mario_Bros_2.png' ); $objects['Coin'] = new Obstacle( 'Coin', 'Coins are added to each level, which reward an extra life.', 'No', 'Yes' ); $objects['Brick'] = new Obstacle( 'Brick', 'Characters cannot get pass through the bricks.', 'No', 'No' ); echo"\nSuperMario: Introduction of Game Objects \n"; $check = 'y'; while ($check == 'y'){ $searchObject = readline("\nEnter the name of the object: \n"); if (isset($objects[$searchObject])) { $objects[$searchObject]->display(); } else { echo "\n Sorry, object not found\n"; } echo "\n"; $check=readline("Do you want to continue? (y/n): "); } ?>
Output for git.master, git.master_jit, rfc.property-hooks
SuperMario: Introduction of Game Objects Fatal error: Uncaught Error: Call to undefined function readline() in /in/JcJNT:76 Stack trace: #0 {main} thrown in /in/JcJNT on line 76
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:
53.86 ms | 401 KiB | 8 Q