3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace StockExample; interface Order { public function execute(); } class Stock { static public function buy(): callable { return function () { echo "You want to buy stocks via callable function" . PHP_EOL; }; // or as callable object // return new StockBuy(); } static public function sell(): callable { return function () { echo "You want to sell stocks via callable function" . PHP_EOL; }; // or as callable object // return new StockSell(); } } class MyCommand implements Order { private $action; public function __construct(callable $action) { $this->action = $action; } public function execute() { // Option 1) use call_user_function call_user_func($this->action); // Option 2) define it as a variable and call it by adding `()` //$action = $this->action; //$action(); } } $bsc = new MyCommand(Stock::buy()); $ssc = new MyCommand(Stock::sell()); $bsc->execute(); $ssc->execute();

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.5.10.0100.00718.81
8.5.00.0160.01120.20
8.4.150.0020.00014.05
8.4.140.0130.01217.80
8.4.130.0090.00317.79
8.4.120.0130.00720.54
8.4.110.0070.00422.51
8.4.100.0090.01318.80
8.4.90.0090.00518.86
8.4.80.0070.00117.99
8.4.70.0110.00917.98
8.4.60.0100.01020.41
8.4.50.0120.00722.12
8.4.40.0130.00618.70
8.4.30.0130.00720.65
8.4.20.0070.00319.92
8.4.10.0030.00619.12
8.3.280.0150.00618.30
8.3.270.0140.00616.82
8.3.260.0140.00516.83
8.3.250.0130.00719.20
8.3.240.0110.00916.52
8.3.230.0140.00616.38
8.3.220.0130.00517.23
8.3.210.0050.00416.64
8.3.200.0110.01016.46
8.3.190.0030.00618.86
8.3.180.0090.01016.34
8.3.170.0130.00618.90
8.3.160.0140.00417.12
8.3.150.0090.00918.93
8.3.140.0050.00316.63
8.3.130.0040.00418.71
8.3.120.0080.01118.64
8.3.110.0040.00420.94
8.3.100.0150.00424.06
8.3.90.0040.00426.77
8.3.80.0090.00016.63
8.3.70.0090.00616.75
8.3.60.0060.00918.31
8.3.50.0090.00724.38
8.3.40.0030.01220.34
8.3.30.0140.00718.66
8.3.20.0080.00020.94
8.3.10.0070.00020.29
8.3.00.0080.00022.19
8.2.290.0110.00920.65
8.2.280.0060.01218.46
8.2.270.0150.00317.08
8.2.260.0130.00618.31
8.2.250.0000.00818.32
8.2.240.0090.00017.14
8.2.230.0030.00622.58
8.2.220.0070.01337.54
8.2.210.0130.00726.77
8.2.200.0060.00316.75
8.2.190.0110.00416.63
8.2.180.0120.00916.50
8.2.170.0140.00022.96
8.2.160.0030.01021.20
8.2.150.0080.00025.66
8.2.140.0080.00024.66
8.2.130.0000.00726.16
8.2.120.0040.00420.61
8.2.110.0070.00422.31
8.2.100.0040.00817.78
8.2.90.0040.00417.79
8.2.80.0060.00319.16
8.2.70.0030.00617.63
8.2.60.0040.00418.04
8.2.50.0000.00818.07
8.2.40.0000.00818.10
8.2.30.0040.00418.13
8.2.20.0040.00418.06
8.2.10.0040.00419.20
8.2.00.0000.00719.23
8.1.330.0110.00723.72
8.1.320.0090.01016.23
8.1.310.0100.00718.46
8.1.300.0200.00017.79
8.1.290.0090.00018.88
8.1.280.0070.00725.92
8.1.270.0030.00623.85
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0110.00719.21
8.1.230.0040.00722.67
8.1.220.0030.00617.74
8.1.210.0060.00318.77
8.1.200.0030.00717.35
8.1.190.0050.00317.23
8.1.180.0030.00618.10
8.1.170.0040.00418.72
8.1.160.0040.00418.78
8.1.150.0000.00718.78
8.1.140.0000.00718.89
8.1.130.0000.00717.48
8.1.120.0040.00417.47
8.1.110.0000.00717.46
8.1.100.0060.00317.51
8.1.90.0040.00417.45
8.1.80.0040.00417.44
8.1.70.0040.00417.45
8.1.60.0050.00317.64
8.1.50.0040.00417.55
8.1.40.0040.00417.53
8.1.30.0060.00317.69
8.1.20.0030.00517.60
8.1.10.0000.00817.65
8.1.00.0060.00317.48
8.0.300.0040.00421.83
8.0.290.0040.00416.88
8.0.280.0040.00418.32
8.0.270.0080.00018.07
8.0.260.0000.00716.89
8.0.250.0000.00716.96
8.0.240.0000.00816.97
8.0.230.0040.00417.02
8.0.220.0030.00316.96
8.0.210.0030.00316.84
8.0.200.0030.00316.95
8.0.190.0040.00416.95
8.0.180.0040.00417.00
8.0.170.0080.00016.86
8.0.160.0040.00417.02
8.0.150.0070.00016.92
8.0.140.0040.00416.91
8.0.130.0030.00313.38
8.0.120.0040.00416.98
8.0.110.0040.00417.00
8.0.100.0000.00816.77
8.0.90.0090.00016.95
8.0.80.0000.01416.84
8.0.70.0050.00316.95
8.0.60.0040.00416.91
8.0.50.0050.00316.91
8.0.30.0080.00817.29
8.0.20.0110.00816.92
8.0.10.0080.00017.11
8.0.00.0070.01316.49
7.4.330.0000.00515.55
7.4.320.0060.00016.58
7.4.300.0000.00616.59
7.4.290.0020.00516.37
7.4.280.0000.00816.63
7.4.270.0070.00016.63
7.4.260.0030.00313.26
7.4.250.0070.00016.37
7.4.240.0020.00516.53
7.4.230.0000.00716.59
7.4.220.0050.00316.40
7.4.210.0070.01016.45
7.4.200.0050.00216.50
7.4.130.0090.01116.62
7.4.120.0080.00816.71
7.4.110.0190.00016.41
7.4.100.0120.00416.39
7.4.90.0110.00716.53
7.4.80.0190.00619.39
7.4.70.0090.00916.43
7.4.60.0080.00916.42
7.4.50.0060.01216.56
7.4.40.0100.00616.68
7.4.30.0070.01016.32
7.4.20.0060.00916.47
7.4.10.0180.00316.34
7.4.00.0080.00816.59
7.3.330.0050.00316.34
7.3.320.0030.00313.16
7.3.310.0000.00716.17
7.3.300.0030.00316.21
7.3.290.0080.00816.29
7.3.260.0050.01316.54
7.3.230.0100.01316.52
7.3.210.0030.01416.34
7.3.200.0130.00916.31
7.3.190.0110.00616.30
7.3.180.0000.01516.40
7.3.170.0000.01516.57
7.3.160.0060.00916.22
7.3.150.0070.00816.29
7.3.140.0090.00616.23
7.3.130.0070.00716.34
7.3.120.0060.00916.32
7.3.110.0030.01416.28
7.3.100.0090.00616.24
7.3.90.0090.00816.54
7.3.80.0090.00616.28
7.3.70.0110.01116.47
7.3.60.0100.01616.27
7.3.50.0090.00616.27
7.3.40.0040.01116.36
7.3.30.0110.00416.38
7.3.20.0080.00818.32
7.3.10.0070.00718.15
7.3.00.0090.00918.14
7.2.330.0100.01016.74
7.2.310.0100.00616.83
7.2.300.0090.00916.58
7.2.290.0090.00816.91
7.2.280.0090.00616.52
7.2.270.0120.00916.77
7.2.260.0070.00716.48
7.2.250.0030.01316.55
7.2.240.0120.00816.55
7.2.230.0090.00616.65
7.2.220.0030.01516.77
7.2.210.0040.01216.68
7.2.200.0110.00416.74
7.2.190.0040.01116.79
7.2.180.0090.00616.70
7.2.170.0070.00716.63
7.2.160.0140.00016.56
7.2.150.0120.00318.47
7.2.140.0050.01118.42
7.2.130.0060.01018.55
7.2.120.0070.01018.53
7.2.110.0080.00818.46
7.2.100.0060.01018.54
7.2.90.0040.01218.40
7.2.80.0030.01318.52
7.2.70.0100.00718.63
7.2.60.0070.01418.54
7.2.50.0060.01618.41
7.2.40.0040.01818.38
7.2.30.0090.01318.53
7.2.20.0090.00918.54
7.2.10.0080.01218.38
7.2.00.0100.00618.54

preferences:
43.34 ms | 403 KiB | 5 Q