3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Shape { public function area() { return 0; } public function sides () { return 0; } } class Rectangle extends Shape { public function area($width,$length) { $area = $width*$length; echo $area . ", "; } public function sides() { } } class Circle extends Shape { public function area($radius,$pi) { $area = pow($radius, 2)*$pi; echo $area . ", "; } public function sides() { } } class Square extends Shape { public function area($side) { $area = pow($side, 2); echo $area; } } $s = new Rectangle(); $s->area(3,15); $c = new Circle(); $c->area(3,3.14); $q = new Square(); $q->area(3);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Declaration of Rectangle::area($width, $length) must be compatible with Shape::area() in /in/KWBnY on line 17
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: Declaration of Rectangle::area($width, $length) should be compatible with Shape::area() in /in/KWBnY on line 17 Warning: Declaration of Circle::area($radius, $pi) should be compatible with Shape::area() in /in/KWBnY on line 29 Warning: Declaration of Square::area($side) should be compatible with Shape::area() in /in/KWBnY on line 41 45, 28.26, 9
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33
Warning: Declaration of Rectangle::area($width, $length) should be compatible with Shape::area() in /in/KWBnY on line 25 Warning: Declaration of Circle::area($radius, $pi) should be compatible with Shape::area() in /in/KWBnY on line 37 Warning: Declaration of Square::area($side) should be compatible with Shape::area() in /in/KWBnY on line 46 45, 28.26, 9
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Strict Standards: Declaration of Rectangle::area() should be compatible with Shape::area() in /in/KWBnY on line 25 Strict Standards: Declaration of Circle::area() should be compatible with Shape::area() in /in/KWBnY on line 37 Strict Standards: Declaration of Square::area() should be compatible with Shape::area() in /in/KWBnY on line 46 45, 28.26, 9

preferences:
161.84 ms | 402 KiB | 183 Q