3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class CarPrototype { protected $doors; protected $wheels; abstract function __clone(); function getDoors() { return $this->doors; } function setDoors($doors) { $this->doors = $doors; } function __toString() { echo $this->doors . ' ' . $this->wheels; } } class NormalCarPrototype extends CarPrototype { function __construct() { $this->doors = 4; $this->wheels = 4; } function __clone() { } } $car = new NormalCarPrototype(); $sandero = clone $car; $duster = clone $car; echo $sandero;
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
4 4 Fatal error: Uncaught TypeError: CarPrototype::__toString(): Return value must be of type string, none returned in /in/72JKM:19 Stack trace: #0 /in/72JKM(37): CarPrototype->__toString() #1 {main} thrown in /in/72JKM on line 19
Process exited with code 255.
Output for 7.4.0 - 7.4.33
4 4 Fatal error: Uncaught Error: Method NormalCarPrototype::__toString() must return a string value in /in/72JKM:37 Stack trace: #0 {main} thrown in /in/72JKM on line 37
Process exited with code 255.
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
4 4 Recoverable fatal error: Method NormalCarPrototype::__toString() must return a string value in /in/72JKM on line 37
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33
4 4 Catchable fatal error: Method NormalCarPrototype::__toString() must return a string value in /in/72JKM on line 37
Process exited with code 255.

preferences:
258.84 ms | 402 KiB | 322 Q