3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface GoAlgorithm { public function go(); } class GoByDrivingAlgorithm implements GoAlgorithm { public function go() { echo "Now I'm driving." .PHP_EOL; } } class GoByFlying implements GoAlgorithm { public function go() { echo "Now I'm flying." . PHP_EOL; } } class GoByFlyingFast implements GoAlgorithm { public function go() { echo "Now I'm flying fast" . PHP_EOL; } } class Vehicle { private $goAlgorithm; function __construct(GoAlgorithm $goType) { $this->goAlgorithm = $goType; } public function setModeOfTransportation(GoAlgorithm $goType) { $this->goAlgorithm = $goType; } public function drive() { return $this->goAlgorithm->go(); } } // setter injection $streetRacer = new Vehicle(); $streetRacer->setModeOfTransportation(new GoByDrivingAlgorithm()); $formulaone = new Vehicle(); $formulaone->setModeOfTransportation(new GoByDrivingAlgorithm()); $helicopter = new Vehicle(); $helicopter->setModeOfTransportation(new GoByFlying()); $jets = new Vehicle(); $jets->setModeOfTransportation(new GoByFlyingFast()); $streetRacer->drive(); $formulaone->drive(); $helicopter->drive(); $jets->drive(); // constructor injection $streetRacer = new Vehicle(new GoByDrivingAlgorithm()); $formulaone = new Vehicle(new GoByDrivingAlgorithm()); $helicopter = new Vehicle(new GoByFlying()); $jets = new Vehicle(new GoByFlyingFast()); $streetRacer->drive(); $formulaone->drive(); $helicopter->drive(); $jets->drive();

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.3.40.0070.00718.94
8.3.30.0030.01019.09
8.3.20.0080.00020.29
8.3.10.0000.00823.47
8.3.00.0040.00419.38
8.2.170.0080.00822.96
8.2.160.0100.00320.27
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0070.00020.95
8.2.110.0030.00621.93
8.2.100.0030.00919.51
8.2.90.0080.00019.27
8.2.80.0050.00317.97
8.2.70.0040.00417.50
8.2.60.0070.00217.93
8.2.50.0040.00418.07
8.2.40.0000.00818.22
8.2.30.0050.00318.05
8.2.20.0040.00417.80
8.2.10.0080.00018.10
8.2.00.0020.00517.93
8.1.270.0080.00023.82
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0100.00023.91
8.1.230.0080.00419.01
8.1.220.0000.00817.78
8.1.210.0040.00418.77
8.1.200.0030.00717.60
8.1.190.0080.00017.35
8.1.180.0030.00518.10
8.1.170.0000.00918.63
8.1.160.0000.00821.95
8.1.150.0050.00318.88
8.1.140.0040.00417.43
8.1.130.0000.00717.70
8.1.120.0000.00717.40
8.1.110.0040.00417.33
8.1.100.0030.00517.34
8.1.90.0000.00817.51
8.1.80.0000.00817.39
8.1.70.0000.00717.32
8.1.60.0030.00617.61
8.1.50.0040.00417.55
8.1.40.0040.00417.50
8.1.30.0000.00917.48
8.1.20.0040.00417.70
8.1.10.0000.00717.46
8.1.00.0000.00817.44
8.0.300.0070.00018.77
8.0.290.0040.00416.88
8.0.280.0030.00318.56
8.0.270.0000.00716.91
8.0.260.0030.00317.33
8.0.250.0000.00716.96
8.0.240.0040.00416.95
8.0.230.0070.00017.06
8.0.220.0040.00417.00
8.0.210.0000.00716.96
8.0.200.0060.00017.11
8.0.190.0090.00017.06
8.0.180.0070.00017.00
8.0.170.0060.00316.94
8.0.160.0040.00416.98
8.0.150.0000.00716.95
8.0.140.0040.00416.88
8.0.130.0000.00513.47
8.0.120.0000.00916.88
8.0.110.0030.00516.98
8.0.100.0040.00416.98
8.0.90.0050.00316.98
8.0.80.0080.00817.02
8.0.70.0050.00217.08
8.0.60.0060.00317.05
8.0.50.0000.00716.89
8.0.30.0140.00517.16
8.0.20.0140.00517.40
8.0.10.0020.00516.92
8.0.00.0120.00616.93
7.4.330.0030.00315.00
7.4.320.0060.00016.50
7.4.300.0060.00016.48
7.4.290.0040.00416.53
7.4.280.0060.00316.39
7.4.270.0070.00016.63
7.4.260.0030.00313.30
7.4.250.0000.00716.57
7.4.240.0020.00516.61
7.4.230.0040.00416.39
7.4.220.0100.00716.52
7.4.210.0000.01416.68
7.4.200.0070.00016.25
7.4.160.0030.01416.59
7.4.150.0120.00617.40
7.4.140.0090.00917.86
7.4.130.0120.00916.55
7.4.120.0130.00616.42
7.4.110.0120.01216.44
7.4.100.0160.00316.76
7.4.90.0140.00316.51
7.4.80.0030.01419.39
7.4.70.0060.01216.35
7.4.60.0070.01016.64
7.4.50.0000.00816.60
7.4.40.0100.00716.68
7.4.30.0060.00916.67
7.4.00.0070.00914.91
7.3.330.0040.00413.21
7.3.320.0000.00513.18
7.3.310.0040.00416.38
7.3.300.0040.00416.40
7.3.290.0070.01016.41
7.3.280.0090.01116.38
7.3.270.0120.00617.40
7.3.260.0040.02116.55
7.3.250.0050.01716.41
7.3.240.0130.00316.34
7.3.230.0110.00716.53
7.3.210.0030.01516.38
7.3.200.0030.01319.39
7.3.190.0100.00716.37
7.3.180.0130.00316.46
7.3.170.0070.01016.64
7.3.160.0030.01216.30
7.3.120.0060.01214.96
7.3.110.0130.00614.61
7.3.100.0060.01014.83
7.3.90.0090.00614.76
7.3.80.0040.00414.97
7.3.70.0100.00414.74
7.3.60.0030.01214.98
7.3.50.0030.01414.86
7.3.40.0060.00614.92
7.3.30.0120.00414.63
7.3.20.0070.01016.64
7.3.10.0030.00916.50
7.3.00.0050.00716.47
7.2.330.0140.00416.52
7.2.320.0030.01716.42
7.2.310.0130.00416.50
7.2.300.0070.01416.49
7.2.290.0120.00416.34
7.2.250.0160.00314.66
7.2.240.0070.01314.92
7.2.230.0090.00614.88
7.2.220.0100.00714.77
7.2.210.0040.00815.21
7.2.200.0030.00714.93
7.2.190.0070.01114.94
7.2.180.0030.00914.69
7.2.170.0120.00414.71
7.2.160.0030.01314.87
7.2.150.0000.01316.89
7.2.140.0040.00716.66
7.2.130.0070.00816.81
7.2.120.0090.00416.68
7.2.110.0070.00716.81
7.2.100.0070.00716.76
7.2.90.0040.00816.73
7.2.80.0120.00516.60
7.2.70.0080.00616.70
7.2.60.0040.01116.71
7.2.50.0050.01116.81
7.2.40.0050.00916.66
7.2.30.0060.00716.85
7.2.20.0100.00616.71
7.2.10.0040.01016.68
7.2.00.0080.00617.26
7.1.330.0090.00915.71
7.1.320.0000.01415.93
7.1.310.0000.01015.45
7.1.300.0060.00615.68
7.1.290.0030.01015.67
7.1.280.0000.00815.84
7.1.270.0030.01115.51
7.1.260.0060.00615.71
7.1.250.0100.00315.51
7.1.240.0110.00615.70
7.1.230.0000.01215.74
7.1.220.0080.00015.46
7.1.210.0060.00915.66
7.1.200.0060.00815.69
7.1.190.0040.01115.81
7.1.180.0040.00815.75
7.1.170.0040.01115.78
7.1.160.0040.01115.70
7.1.150.0060.00615.81
7.1.140.0080.00415.46
7.1.130.0070.00715.67
7.1.120.0070.00715.83
7.1.110.0060.00615.70
7.1.100.0070.00616.72
7.1.90.0070.00715.69
7.1.80.0030.01015.68
7.1.70.0070.00416.26
7.1.60.0080.01117.51
7.1.50.0090.00416.38
7.1.40.0100.00315.80
7.1.30.0030.00715.70
7.1.20.0040.00815.75
7.1.10.0060.00615.66
7.1.00.0080.03719.18
7.0.330.0030.01015.27
7.0.320.0090.00415.38
7.0.310.0100.00315.23
7.0.300.0090.00315.33
7.0.290.0060.00615.41
7.0.280.0030.00515.55
7.0.270.0080.00315.46
7.0.260.0040.00815.35
7.0.250.0070.00415.38
7.0.240.0000.01615.50
7.0.230.0130.00015.41
7.0.220.0030.01215.41
7.0.210.0030.01015.36
7.0.200.0060.00315.76
7.0.190.0040.00815.35
7.0.180.0080.00315.32
7.0.170.0090.00615.51
7.0.160.0040.01115.27
7.0.150.0030.00715.50
7.0.140.0030.04218.68
7.0.130.0070.00715.06
7.0.120.0090.00315.53
7.0.110.0050.00515.17
7.0.100.0030.00815.31
7.0.90.0030.01015.34
7.0.80.0120.00015.27
7.0.70.0060.00315.57
7.0.60.0030.04217.61
7.0.50.0040.02716.52
7.0.40.0040.03616.90
7.0.30.0100.03716.66
7.0.20.0150.04116.76
7.0.10.0150.03216.81
7.0.00.0050.04716.74
5.6.400.0040.00814.23
5.6.390.0000.01314.42
5.6.380.0110.00014.14
5.6.370.0030.01214.35
5.6.360.0030.00514.29
5.6.350.0040.00414.32
5.6.340.0030.01014.55
5.6.330.0090.00314.29
5.6.320.0000.01213.86
5.6.310.0060.00313.95
5.6.300.0070.00414.26
5.6.290.0070.00714.29
5.6.280.0070.03317.65
5.6.270.0060.00314.30
5.6.260.0070.00714.39
5.6.250.0060.00613.97
5.6.240.0140.00014.39
5.6.230.0040.01114.14
5.6.220.0000.00914.11
5.6.210.0100.03717.59
5.6.200.0080.02716.23
5.6.190.0030.03017.42
5.6.180.2130.02817.42
5.6.170.0150.03017.34
5.6.160.0050.02617.26
5.6.150.0090.03016.29
5.6.140.0110.03816.16
5.6.130.0090.02216.30
5.6.120.0140.03717.67
5.6.110.0070.04517.58
5.6.100.0090.02917.48
5.6.90.0030.03017.63
5.6.80.0070.02317.43
5.6.70.0130.04117.22
5.6.60.0070.00713.95
5.6.50.0030.01013.93
5.6.40.0090.00914.25
5.6.30.0030.01413.91
5.6.20.0060.00614.31
5.6.10.0070.00714.09
5.6.00.0030.01014.02
5.5.380.0090.00614.20
5.5.370.0030.01414.25
5.5.360.0090.00414.34
5.5.350.0200.03717.34
5.5.340.0050.02316.09
5.5.330.0050.04717.17
5.5.320.0280.03517.35
5.5.310.0100.04917.29
5.5.300.0080.03015.99
5.5.290.0100.03816.11
5.5.280.0070.02317.49
5.5.270.0030.05017.38
5.5.260.0080.02317.67
5.5.250.0050.02317.33
5.5.240.1650.03017.25
5.5.230.0080.00513.89
5.5.220.0030.01314.19
5.5.210.0080.00014.22
5.5.200.0000.01513.80
5.5.190.0000.00814.20
5.5.180.0040.00713.92
5.5.170.0090.00613.93
5.5.160.0110.00313.78
5.5.150.0110.00414.21
5.5.140.0000.00914.37
5.5.130.0120.00614.30
5.5.120.0030.01314.27
5.5.110.0070.00714.11
5.5.100.0080.00414.39
5.5.90.0060.00614.16
5.5.80.0130.00014.30
5.5.70.0030.01014.18
5.5.60.0070.00714.22
5.5.50.0060.00913.92
5.5.40.0060.00314.27
5.5.30.0040.00814.03
5.5.20.0080.00813.90
5.5.10.0000.01014.22
5.5.00.0030.01013.92
5.4.450.0230.02315.15
5.4.440.0280.02015.13
5.4.430.0290.02015.15
5.4.420.0150.03015.21
5.4.410.0300.03315.18
5.4.400.0270.02014.93
5.4.390.0270.03614.83
5.4.380.0250.02514.94
5.4.370.0310.02315.09
5.4.360.0190.02514.86
5.4.350.0200.02315.16
5.4.340.0250.03915.01
5.4.330.0000.01010.70
5.4.320.0240.02215.07
5.4.310.0250.03314.85
5.4.300.0330.03014.87
5.4.290.0300.03014.97
5.4.280.0270.02915.00
5.4.270.0260.03814.94
5.4.260.0230.02215.03
5.4.250.0230.02714.80
5.4.240.0270.03515.02
5.4.230.0230.03714.97
5.4.220.0300.03315.01
5.4.210.0230.02814.98
5.4.200.0280.03214.79
5.4.190.0300.02815.19
5.4.180.0350.03015.09
5.4.170.0300.02814.92
5.4.160.0250.03214.70
5.4.150.0230.02114.86
5.4.140.0280.03013.65
5.4.130.0320.03113.75
5.4.120.0250.03313.61
5.4.110.0320.02713.53
5.4.100.0390.01413.78
5.4.90.0290.03613.76
5.4.80.0230.03813.68
5.4.70.0220.02513.68
5.4.60.0180.02513.77
5.4.50.0280.03313.63
5.4.40.0280.03413.74
5.4.30.0280.02713.63
5.4.20.0270.01713.67
5.4.10.0280.02213.55
5.4.00.0280.03513.30
5.3.290.0370.04314.73
5.3.280.0430.04014.71
5.3.270.0330.03714.77
5.3.260.0430.06314.63
5.3.250.0530.05714.65
5.3.240.0500.03714.63
5.3.230.0500.06014.70
5.3.220.0370.05314.50
5.3.210.0430.04014.64
5.3.200.0300.03714.70
5.3.190.0330.03714.52
5.3.180.0370.06314.67
5.3.170.0270.05314.59
5.3.160.0400.06714.59
5.3.150.0430.03014.52
5.3.140.0570.04014.70
5.3.130.0300.04014.63
5.3.120.0400.06714.48
5.3.110.0300.05314.80
5.3.100.0400.05714.05
5.3.90.0370.03314.09
5.3.80.0270.04313.94
5.3.70.0230.04314.10
5.3.60.0230.04313.94
5.3.50.0330.05014.20
5.3.40.0400.07313.98
5.3.30.0470.05713.95
5.3.20.0430.03713.94
5.3.10.0470.05013.62
5.3.00.0430.03313.67
5.2.170.0370.03712.38
5.2.160.0400.03012.38
5.2.150.0370.02712.38
5.2.140.0300.03312.38
5.2.130.0300.03012.38
5.2.120.0370.04012.38
5.2.110.0470.05012.38
5.2.100.0330.04312.38
5.2.90.0470.03012.38
5.2.80.0430.03312.38
5.2.70.0330.04012.38
5.2.60.0430.05312.38
5.2.50.0370.04312.38
5.2.40.0330.03312.38
5.2.30.0370.04712.38
5.2.20.0330.05712.38
5.2.10.0370.03712.38
5.2.00.0370.04712.38
5.1.60.0330.03312.38
5.1.50.0370.04312.38
5.1.40.0300.03012.38
5.1.30.0230.03012.38
5.1.20.0400.04312.38
5.1.10.0330.02012.38
5.1.00.0270.02712.38
5.0.50.0170.02312.38
5.0.40.0200.04312.38
5.0.30.0130.03312.38
5.0.20.0200.04012.38
5.0.10.0200.04012.38
5.0.00.0200.04012.38
4.4.90.0170.01712.38
4.4.80.0170.01312.38
4.4.70.0130.02712.38
4.4.60.0170.02312.38
4.4.50.0200.03012.38
4.4.40.0230.04312.38
4.4.30.0170.03312.38
4.4.20.0170.03712.38
4.4.10.0200.02312.38
4.4.00.0170.03712.38
4.3.110.0130.02012.38
4.3.100.0170.01312.38
4.3.90.0130.02312.38
4.3.80.0130.03012.38
4.3.70.0170.02712.38
4.3.60.0130.02312.38
4.3.50.0170.03712.38
4.3.40.0170.03012.38
4.3.30.0070.02012.38
4.3.20.0070.03312.38
4.3.10.0130.03012.38
4.3.00.0100.02312.38

preferences:
47.42 ms | 400 KiB | 5 Q