3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Vehicle { /** * @var string */ private $name; protected static $type = 'vehicle'; /** * Vehicle constructor. * * @param $name */ public function __construct($name) { $this->name = $name; } /** * @param $type * @return static */ public static function createStatic($type) { return new static($type); } /** * @param $type * @return \Vehicle */ public static function createSelf($type) { return new self($type); } /** * @return string */ public function getStaticType() { return static::$type; } /** * @return string */ public function getSelfType() { return self::$type; } } class Bicycle extends Vehicle { protected static $type = 'bicycle'; /**getSelfType * @inheritDoc */ public function __construct($name) { parent::__construct($name); } } class Car extends Vehicle { protected static $type = 'car'; /** * @inheritDoc */ public function __construct($name) { parent::__construct($name); } } $vehicle = new Vehicle('vehicle1'); $bicycle = new Bicycle('bicycle1'); $car = new Car('car1'); var_dump('new Vehicle(\'vehicle\') is a ' . get_class($vehicle)); var_dump('new Bicycle(\'bicycle\') is a ' . get_class($bicycle)); var_dump('new Car(\'car\') is a ' . get_class($car)); var_dump('$car->getSelfType() is ' . $car->getSelfType()); var_dump('$car->getStaticType() is ' . $car->getStaticType()); $staticThing1 = Vehicle::createStatic('staticThing1'); $staticThing2 = Bicycle::createStatic('staticThing2'); $staticThing3 = Car::createStatic('staticThing3'); var_dump('Vehicle::createStatic(\'staticThing1\') is a ' . get_class($staticThing1)); var_dump('Bicycle::createStatic(\'staticThing2\') is a ' . get_class($staticThing2)); var_dump('Car::createStatic(\'staticThing3\') is a ' . get_class($staticThing3)); var_dump('$staticThing3->getSelfType() is ' . $staticThing3->getSelfType()); var_dump('$staticThing3->getStaticType() is ' . $staticThing3->getStaticType()); $selfThing1 = Vehicle::createSelf('selfThing1'); $selfThing2 = Bicycle::createSelf('selfThing2'); $selfThing3 = Car::createSelf('selfThing3'); var_dump('Vehicle::createSelf(\'selfThing1\') is a ' . get_class($selfThing1)); var_dump('Bicycle::createSelf(\'selfThing2\') is a ' . get_class($selfThing2)); var_dump('Car::createSelf(\'selfThing3\') is a ' . get_class($selfThing3)); var_dump('$selfThing3->getSelfType() is ' . $selfThing3->getSelfType()); var_dump('$selfThing3->getStaticType() is ' . $selfThing3->getStaticType());

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.4.130.0150.00617.49
8.4.120.0040.00423.89
8.4.110.0130.00717.73
8.4.100.0120.00818.02
8.4.90.0110.01018.67
8.4.80.0130.00617.74
8.4.70.0120.00617.87
8.4.60.0130.00918.89
8.4.50.0110.00824.21
8.4.40.0130.00717.61
8.4.30.0130.00719.17
8.4.20.0100.01017.57
8.4.10.0090.00017.56
8.3.260.0110.00516.80
8.3.250.0100.00819.02
8.3.240.0120.00717.05
8.3.230.0100.01016.48
8.3.220.0100.00817.27
8.3.210.0120.00816.57
8.3.200.0040.00516.66
8.3.190.0150.00517.12
8.3.180.0060.00416.64
8.3.170.0000.01317.48
8.3.160.0130.00618.24
8.3.150.0130.00619.14
8.3.140.0070.00416.45
8.3.130.0080.00016.58
8.3.120.0120.00620.93
8.3.110.0040.00420.94
8.3.100.0060.00324.06
8.3.90.0040.00426.77
8.3.80.0050.00516.63
8.3.70.0090.00618.18
8.3.60.0040.01116.61
8.3.50.0120.00917.50
8.3.40.0090.00618.68
8.3.30.0040.01118.84
8.3.20.0000.00720.29
8.3.10.0040.00422.14
8.3.00.0050.00323.48
8.2.290.0100.00920.52
8.2.280.0080.00918.48
8.2.270.0150.00317.59
8.2.260.0040.00416.59
8.2.250.0060.00316.56
8.2.240.0030.00617.21
8.2.230.0000.00822.58
8.2.220.0050.00537.54
8.2.210.0060.00326.77
8.2.200.0040.00416.38
8.2.190.0090.00616.88
8.2.180.0090.00616.50
8.2.170.0140.00722.96
8.2.160.0000.01419.24
8.2.150.0050.00324.18
8.2.140.0050.00324.66
8.2.130.0040.00419.08
8.2.120.0050.00326.35
8.2.110.0040.00719.38
8.2.100.0060.00617.78
8.2.90.0040.00419.22
8.2.80.0040.00419.20
8.2.70.0080.00017.50
8.2.60.0060.00617.93
8.2.50.0030.00618.10
8.2.40.0040.00420.55
8.2.30.0040.00419.37
8.2.20.0040.00418.07
8.2.10.0060.00318.06
8.2.00.0060.00318.06
8.1.330.0090.00922.28
8.1.320.0110.00818.49
8.1.310.0020.00516.63
8.1.300.0130.00720.34
8.1.290.0000.01030.84
8.1.280.0100.01025.92
8.1.270.0080.00023.97
8.1.260.0060.00326.35
8.1.250.0050.00328.09
8.1.240.0030.00621.20
8.1.230.0070.00420.36
8.1.220.0030.00517.74
8.1.210.0000.00818.77
8.1.200.0060.00317.38
8.1.190.0030.00517.48
8.1.180.0030.00518.10
8.1.170.0040.00418.65
8.1.160.0040.00418.88
8.1.150.0000.00820.17
8.1.140.0070.00019.57
8.1.130.0030.00317.39
8.1.120.0020.00517.39
8.1.110.0000.00817.43
8.1.100.0000.00917.48
8.1.90.0040.00417.41
8.1.80.0030.00417.35
8.1.70.0040.00417.38
8.1.60.0060.00317.68
8.1.50.0060.00617.58
8.1.40.0030.00517.46
8.1.30.0000.00817.54
8.1.20.0080.00017.69
8.1.10.0080.00017.52
8.1.00.0040.00417.62
8.0.300.0070.00018.77
8.0.290.0000.00816.75
8.0.280.0040.00418.43
8.0.270.0070.00017.28
8.0.260.0000.00716.86
8.0.250.0030.00316.93
8.0.240.0090.00017.06
8.0.230.0070.00017.02
8.0.220.0040.00416.84
8.0.210.0070.00016.94
8.0.200.0090.00016.88
8.0.190.0060.00316.92
8.0.180.0040.00416.93
8.0.170.0030.00317.03
8.0.160.0000.00716.94
8.0.150.0040.00416.78
8.0.140.0040.00416.84
8.0.130.0000.00513.41
8.0.120.0070.00016.94
8.0.110.0070.00016.86
8.0.100.0000.00716.87
8.0.90.0000.00716.87
8.0.80.0060.01116.87
8.0.70.0070.00016.75
8.0.60.0000.00716.74
8.0.50.0050.00216.72
8.0.30.0080.01117.10
8.0.20.0090.01117.40
8.0.10.0040.00417.00
8.0.00.0100.00716.59
7.4.330.0000.00515.55
7.4.320.0000.00716.60
7.4.300.0000.00616.66
7.4.290.0040.00416.57
7.4.280.0060.00316.64
7.4.270.0050.00316.61
7.4.260.0000.00716.57
7.4.250.0040.00416.61
7.4.240.0080.00016.59
7.4.230.0070.00016.70
7.4.220.0130.01216.63
7.4.210.0040.01416.63
7.4.200.0040.00416.45
7.4.160.0070.00916.50
7.4.150.0030.01417.40
7.4.140.0130.00817.86
7.4.130.0160.00616.65
7.4.120.0100.01116.51
7.4.110.0040.01416.77
7.4.100.0080.01016.81
7.4.90.0090.00916.67
7.4.80.0090.00919.39
7.4.70.0140.00316.49
7.4.60.0000.01716.49
7.4.50.0030.01016.44
7.4.40.0110.01116.68
7.4.30.0090.00916.72
7.4.00.0030.01014.97
7.3.330.0060.00013.44
7.3.320.0050.00013.41
7.3.310.0080.00016.40
7.3.300.0070.00016.28
7.3.290.0000.00716.43
7.3.280.0100.01016.39
7.3.270.0190.00317.40
7.3.260.0160.00616.60
7.3.250.0150.00416.43
7.3.240.0090.00816.51
7.3.230.0130.00316.66
7.3.210.0090.00916.39
7.3.200.0070.01016.43
7.3.190.0100.00716.52
7.3.180.0070.01316.63
7.3.170.0130.00316.44
7.3.160.0110.00816.41
7.2.330.0070.01116.79
7.2.320.0030.01316.49
7.2.310.0060.01216.73
7.2.300.0170.00016.85
7.2.290.0080.00816.80
7.2.60.0100.00316.94
7.1.200.0000.01415.81
7.1.90.0000.01518.07
7.1.80.0030.01018.00
7.1.70.0030.01017.19
7.1.60.0150.01135.09
7.1.50.0190.00834.92
7.1.40.0170.01034.59
7.1.30.0160.01034.33
7.1.20.0130.01334.54
7.1.10.0040.00816.62
7.1.00.0070.00716.63
7.0.230.0030.01017.77
7.0.220.0080.00517.59
7.0.210.0060.00616.67
7.0.200.0100.00316.90
7.0.190.0030.01016.56
7.0.180.0040.00816.42
7.0.170.0080.00516.19
7.0.160.0030.00916.45
7.0.150.0000.01216.17
7.0.140.0090.00316.31
7.0.130.0090.00316.68
7.0.120.0000.01216.60
7.0.110.0000.01316.50
7.0.100.0000.01216.34
7.0.90.0030.01316.21
7.0.80.0060.00916.30
7.0.70.0100.00716.21
7.0.60.0090.00316.15
7.0.50.0000.01116.25
7.0.40.0000.01216.33
7.0.30.0030.00916.36
7.0.20.0000.01216.36
7.0.10.0030.01316.36
7.0.00.0090.00916.31

preferences:
76.46 ms | 403 KiB | 5 Q