3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace StockExample; interface Order { public function execute(); } class Stock { public function buy(): callable { return function () { echo "You want to buy stocks via callable function" . PHP_EOL; }; } public function sell(): callable { return function () { echo "You want to sell stocks via callable function" . PHP_EOL; }; } } 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(); } } // example with a callable function $stock = new Stock(); $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.0110.00818.95
8.5.00.0130.01219.90
8.4.160.0110.01023.91
8.4.150.0030.00014.05
8.4.140.0110.01017.54
8.4.130.0060.00417.85
8.4.120.0150.00520.59
8.4.110.0110.00920.74
8.4.100.0160.00517.50
8.4.90.0130.00817.82
8.4.80.0110.00717.91
8.4.70.0040.00417.79
8.4.60.0040.00418.88
8.4.50.0100.01217.80
8.4.40.0180.00318.71
8.4.30.0090.00920.40
8.4.20.0100.01019.50
8.4.10.0030.00619.51
8.3.280.0100.01018.32
8.3.270.0170.00416.78
8.3.260.0120.00816.66
8.3.250.0100.00920.63
8.3.240.0120.00716.66
8.3.230.0110.00716.79
8.3.220.0120.00716.61
8.3.210.0050.00218.75
8.3.200.0040.00416.71
8.3.190.0050.00318.98
8.3.180.0110.00816.58
8.3.170.0160.00617.15
8.3.160.0110.00016.59
8.3.150.0060.01217.19
8.3.140.0110.00417.06
8.3.130.0090.00918.26
8.3.120.0000.00819.11
8.3.110.0080.00016.54
8.3.100.0060.00324.06
8.3.90.0040.01118.32
8.3.80.0090.00018.15
8.3.70.0070.00716.50
8.3.60.0090.00918.43
8.3.50.0100.01024.44
8.3.40.0100.00720.29
8.3.30.0150.00818.71
8.3.20.0000.00720.86
8.3.10.0080.00020.10
8.3.00.0070.00722.52
8.2.290.0060.00220.62
8.2.280.0110.00718.51
8.2.270.0070.00716.89
8.2.260.0110.00718.98
8.2.250.0110.00716.63
8.2.240.0030.00617.48
8.2.230.0090.00020.94
8.2.220.0060.01037.54
8.2.210.0060.01326.77
8.2.200.0060.00316.50
8.2.190.0160.00616.63
8.2.180.0120.00616.63
8.2.170.0150.00622.96
8.2.160.0090.00621.10
8.2.150.0030.00924.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0040.00421.04
8.2.110.0090.00021.04
8.2.100.0080.00317.72
8.2.90.0050.00317.50
8.2.80.0080.00018.86
8.2.70.0080.00018.03
8.2.60.0030.00718.22
8.2.50.0000.00719.31
8.2.40.0050.00321.07
8.2.30.0000.00819.28
8.2.20.0030.00518.03
8.2.10.0040.00419.18
8.2.00.0000.00819.26
8.1.330.0150.00421.96
8.1.320.0110.00716.20
8.1.310.0000.00816.87
8.1.300.0040.00419.88
8.1.290.0030.00718.88
8.1.280.0070.00725.92
8.1.270.0000.00722.05
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0050.00519.13
8.1.230.0040.00722.67
8.1.220.0040.00417.75
8.1.210.0090.00018.77
8.1.200.0060.00317.38
8.1.190.0080.00017.35
8.1.180.0070.00018.89
8.1.170.0100.00018.66
8.1.160.0040.00418.96
8.1.150.0000.00818.95
8.1.140.0070.00018.94
8.1.130.0040.00421.96
8.1.120.0050.00217.50
8.1.110.0070.00017.43
8.1.100.0040.00417.32
8.1.90.0040.00417.36
8.1.80.0050.00217.47
8.1.70.0000.00817.39
8.1.60.0060.00317.48
8.1.50.0050.00317.54
8.1.40.0000.00717.59
8.1.30.0080.00017.58
8.1.20.0000.00817.65
8.1.10.0040.00417.60
8.1.00.0060.00317.50
8.0.300.0030.00618.77
8.0.290.0060.00316.75
8.0.280.0030.00518.48
8.0.270.0030.00718.67
8.0.260.0000.00620.07
8.0.250.0080.00016.96
8.0.240.0000.00617.02
8.0.230.0040.00416.96
8.0.220.0030.00316.83
8.0.210.0060.00016.91
8.0.200.0000.00617.01
8.0.190.0000.00717.00
8.0.180.0040.00416.95
8.0.170.0030.00616.86
8.0.160.0000.00716.85
8.0.150.0070.00016.81
8.0.140.0040.00416.96
8.0.130.0000.00513.43
8.0.120.0040.00416.86
8.0.110.0000.00716.76
8.0.100.0040.00416.98
8.0.90.0040.00416.85
8.0.80.0090.00616.93
8.0.70.0000.00816.86
8.0.60.0070.00016.78
8.0.50.0050.00216.75
8.0.30.0130.00317.06
8.0.20.0080.01117.01
8.0.10.0070.00016.90
8.0.00.0120.00616.69
7.4.330.0000.00515.55
7.4.320.0060.00016.64
7.4.300.0030.00316.61
7.4.290.0070.00016.45
7.4.280.0070.00016.50
7.4.270.0000.00816.52
7.4.260.0030.00313.28
7.4.250.0000.00816.48
7.4.240.0040.00416.51
7.4.230.0000.00716.32
7.4.220.0000.00716.61
7.4.210.0090.00916.50
7.4.200.0000.00716.63
7.4.130.0110.01116.51
7.4.120.0040.01316.49
7.4.110.0100.00716.52
7.4.100.0040.01316.54
7.4.90.0100.00716.57
7.4.80.0130.00419.39
7.4.70.0090.00916.44
7.4.60.0140.00316.34
7.4.50.0120.00416.48
7.4.40.0040.01416.53
7.4.30.0080.01316.44
7.4.20.0140.01816.60
7.4.10.0270.00916.61
7.4.00.0110.01016.66
7.3.330.0030.00316.32
7.3.320.0030.00313.16
7.3.310.0060.00016.34
7.3.300.0070.00016.31
7.3.290.0090.00816.28
7.3.280.0090.00616.23
7.3.260.0140.00516.41
7.3.230.0120.00616.41
7.3.210.0090.00616.29
7.3.200.0120.00816.25
7.3.190.0000.01616.30
7.3.180.0090.00616.30
7.3.170.0030.01216.35
7.3.160.0080.01016.33
7.3.150.0230.01016.18
7.3.140.0240.00916.58
7.3.130.0270.01516.21
7.3.120.0230.01016.61
7.3.110.0190.01516.53
7.3.100.0230.01016.19
7.3.90.0270.00816.22
7.3.80.0240.00916.38
7.3.70.0250.00316.37
7.3.60.0160.00516.35
7.3.50.0180.00916.21
7.3.40.0160.01416.28
7.3.30.0160.01216.22
7.3.20.0240.00316.29
7.3.10.0080.01716.32
7.3.00.0150.01216.34
7.2.330.0000.01816.82
7.2.320.0060.01216.62
7.2.310.0060.01116.76
7.2.300.0100.01016.76
7.2.290.0060.01216.86
7.2.280.0230.01316.70
7.2.270.0200.01716.74
7.2.260.0350.00516.69
7.2.250.0210.01416.66
7.2.240.0210.01216.85
7.2.230.0210.01416.68
7.2.220.0180.01116.73
7.2.210.0170.01016.70
7.2.200.0220.00316.68
7.2.190.0280.00016.71
7.2.180.0200.00316.59
7.2.170.0140.01216.70
7.2.160.0140.00916.57
7.2.150.0100.01016.64
7.2.140.0120.01616.61
7.2.130.0120.01616.85
7.2.120.0200.00416.67
7.2.110.0150.00816.60
7.2.100.0230.00516.71
7.2.90.0070.01416.73
7.2.80.0100.01416.80
7.2.70.0120.01516.61
7.2.60.0070.01816.41
7.2.50.0210.00416.64
7.2.40.0140.00816.84
7.2.30.0090.01516.87
7.2.20.0310.01416.50
7.2.10.0190.00416.65
7.2.00.0160.00816.63

preferences:
35.15 ms | 403 KiB | 5 Q