3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Shape { public function __construct() {} abstract public function area(); abstract public function sides(); public function info() { return "This ".get_class($this)." has ".$this->sides()." sides and an area of ".$this->area()."\n"; } } class Square extends Shape { public function __construct($s) { parent::__construct(); $this->width = $s; } public function area() { return $this->width * $this-width; } public function sides() { return 4; } } class Rectangle extends Square { public function __construct($w,$h) { parent::__construct($w); $this->height = $h; } public function area() { return $this->width * $this->height; } } class Circle extends Shape { public function __construct($r) { parent::__construct(); $this->radius = $r; } public function area() { return $this->radius * $this->radius * M_PI; } public function sides() { return 1; } } $s = new Rectangle(3,15); print($s->info()); $c = new Circle(3); print($c->info()); $q = new Square(3); print($q->info()); ?>
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property Rectangle::$width is deprecated in /in/D51ZQ on line 21 Deprecated: Creation of dynamic property Rectangle::$height is deprecated in /in/D51ZQ on line 40 This Rectangle has 4 sides and an area of 45 Deprecated: Creation of dynamic property Circle::$radius is deprecated in /in/D51ZQ on line 54 This Circle has 1 sides and an area of 28.274333882308 Deprecated: Creation of dynamic property Square::$width is deprecated in /in/D51ZQ on line 21 Fatal error: Uncaught TypeError: Unsupported operand types: int * Square in /in/D51ZQ:26 Stack trace: #0 /in/D51ZQ(12): Square->area() #1 /in/D51ZQ(73): Shape->info() #2 {main} thrown in /in/D51ZQ on line 26
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:
47.82 ms | 402 KiB | 8 Q