3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * This class implements ArrayAccess and the magic * isset method to test the behavior of certain operators * * It simulates having just a property called a */ class Test implements ArrayAccess { public function __isset($property) { return $property === 'a'; } public function __get($property) { return $property === 'a'? 'a' : null; } public function offsetExists ( $offset ) : bool { return $offset === 'a'; } /** * We are required by the interface to implement these methods * but they're irrelevant to our test */ public function offsetGet ( $offset ) { return $offset === 'a'? 'a' : null; } public function offsetSet ($offset , $value ) : void { return; } public function offsetUnset ($offset ) : void { return; } } /** * Start performing the actual tests, we wanna compare the * behavior of isset() and the ?? operator */ $tests = [ 'isset->a' => function($e) { return isset($e->a) && $e->a? $e->a : false; }, 'isset->b' => function($e) { return isset($e->b) && $e->b? $e->b : false; }, 'isset[a]' => function($e) { return isset($e['a']) && $e['a']? $e['a'] : false; }, 'isset[b]' => function($e) { return isset($e['b']) && $e['b']? $e['b'] : false; }, '[a]??false' => function($e) { return $e['a']??false; }, '[b]??false' => function($e) { return $e['b']??false; }, '->a??false' => function($e) { return $e->a??false; }, '->b??false' => function($e) { return $e->b??false; } ]; $a = new Test(); foreach ($tests as $caption => $fn) { echo $caption, ': ', ($fn($a)? $fn($a) : 'false'), PHP_EOL; }

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.30.0130.00617.46
8.5.20.0100.00921.08
8.5.10.0120.00518.41
8.5.00.0120.00920.03
8.4.180.0100.01124.02
8.4.170.0140.00722.01
8.4.160.0130.00922.32
8.4.150.0080.00416.91
8.4.140.0130.00817.78
8.4.130.0040.00518.02
8.4.120.0100.00924.11
8.4.110.0070.00524.48
8.4.100.0100.01018.84
8.4.90.0060.00520.64
8.4.80.0070.00618.77
8.4.70.0120.00818.03
8.4.60.0160.00518.70
8.4.50.0080.01420.35
8.4.40.0040.00419.62
8.4.30.0100.01020.39
8.4.20.0040.00718.86
8.4.10.0060.00318.02
8.3.300.0100.00720.32
8.3.290.0120.00820.93
8.3.280.0100.01118.70
8.3.270.0120.00816.86
8.3.260.0040.00516.78
8.3.250.0110.00818.84
8.3.240.0120.00717.05
8.3.230.0080.01116.78
8.3.220.0060.00218.92
8.3.210.0150.00517.07
8.3.200.0050.00416.95
8.3.190.0150.00417.35
8.3.180.0090.00917.28
8.3.170.0000.00717.10
8.3.160.0120.00316.89
8.3.150.0030.00718.59
8.3.140.0040.00417.18
8.3.130.0040.00418.41
8.3.120.0030.00620.41
8.3.110.0040.00420.94
8.3.100.0060.00324.06
8.3.90.0060.00326.77
8.3.80.0060.00318.68
8.3.70.0100.01016.63
8.3.60.0200.00016.75
8.3.50.0090.00819.10
8.3.40.0040.01818.97
8.3.30.0070.01118.56
8.3.20.0000.00720.81
8.3.10.0060.00321.79
8.3.00.0040.00420.70
8.2.300.0140.00622.00
8.2.290.0060.00220.82
8.2.280.0070.00118.97
8.2.270.0070.01317.38
8.2.260.0030.00716.70
8.2.250.0000.00916.70
8.2.240.0060.00317.12
8.2.230.0040.00422.58
8.2.220.0060.00337.54
8.2.210.0040.00426.77
8.2.200.0060.00318.42
8.2.190.0100.01017.00
8.2.180.0150.00925.92
8.2.170.0140.00719.13
8.2.160.0100.00322.00
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0040.00426.16
8.2.120.0040.00426.16
8.2.110.0040.00420.47
8.2.100.0090.00317.91
8.2.90.0000.00819.79
8.2.80.0000.00818.03
8.2.70.0030.00618.03
8.2.60.0040.00418.16
8.2.50.0040.00418.10
8.2.40.0000.00921.12
8.2.30.0080.00019.23
8.2.20.0000.00718.06
8.2.10.0090.00019.40
8.2.00.0070.00019.37
8.1.340.0130.00721.77
8.1.330.0120.00722.07
8.1.320.0090.00416.30
8.1.310.0040.00418.05
8.1.300.0090.00618.04
8.1.290.0060.00330.84
8.1.280.0070.00725.92
8.1.270.0040.00423.97
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00323.80
8.1.230.0040.00721.02
8.1.220.0000.00817.91
8.1.210.0080.00018.77
8.1.200.0060.00317.48
8.1.190.0030.00617.23
8.1.180.0060.00318.10
8.1.170.0000.00818.64
8.1.160.0040.00419.04
8.1.150.0000.00718.87
8.1.140.0000.00720.39
8.1.130.0070.00020.21
8.1.120.0000.00717.39
8.1.110.0050.00317.38
8.1.100.0050.00317.55
8.1.90.0080.00317.51
8.1.80.0030.00517.38
8.1.70.0030.00517.45
8.1.60.0030.00617.66
8.1.50.0000.00817.50
8.1.40.0090.00017.57
8.1.30.0040.00417.55
8.1.20.0040.00417.68
8.1.10.0000.00817.51
8.1.00.0040.00417.46
8.0.300.0070.00019.73
8.0.290.0080.00016.63
8.0.280.0000.00718.39
8.0.270.0040.00417.17
8.0.260.0000.00720.06
8.0.250.0000.00817.00
8.0.240.0000.00716.88
8.0.230.0040.00416.96
8.0.220.0030.00316.92
8.0.210.0000.00816.91
8.0.200.0000.00716.91
8.0.190.0000.00716.90
8.0.180.0050.00216.81
8.0.170.0040.00416.87
8.0.160.0040.00416.88
8.0.150.0070.00016.94
8.0.140.0040.00416.78
8.0.130.0060.00013.34
8.0.120.0080.00016.89
8.0.110.0080.00016.79
8.0.100.0050.00216.87
8.0.90.0030.00516.79
8.0.80.0120.00316.92
8.0.70.0040.00416.76
8.0.60.0040.00416.71
8.0.50.0030.00516.95
8.0.30.0170.00017.06
8.0.20.0000.01916.86
8.0.10.0070.00017.05
8.0.00.0060.01316.99
7.4.330.0000.00515.55
7.4.320.0000.00616.63
7.4.300.0000.00616.64
7.4.290.0000.00916.50
7.4.280.0040.00416.63
7.4.270.0000.00716.54
7.4.260.0060.00013.36
7.4.250.0030.00516.52
7.4.240.0030.00516.51
7.4.230.0030.00516.44
7.4.220.0040.00416.59
7.4.210.0090.00916.59
7.4.200.0070.00016.43
7.4.130.0100.01316.40
7.4.120.0120.00916.73
7.4.110.0130.00616.61
7.4.100.0140.00716.55
7.4.90.0160.00316.46
7.4.80.0060.01619.39
7.4.70.0090.01216.50
7.4.60.0070.01116.45
7.4.50.0090.00916.46
7.4.40.0070.01016.57
7.4.00.0070.01015.14
7.3.330.0000.00816.35
7.3.320.0030.00313.37
7.3.310.0030.00316.39
7.3.300.0030.00316.36
7.3.290.0030.00316.24
7.3.260.0150.00616.43
7.3.240.0110.01016.44
7.3.230.0060.01116.61
7.3.210.0110.00616.41
7.3.200.0030.01216.34
7.3.190.0070.01116.34
7.3.180.0130.00316.63
7.3.170.0170.00416.56
7.3.160.0090.00616.63
7.3.100.0110.00514.73
7.3.90.0140.00614.59
7.3.80.0100.01014.88
7.3.70.0100.01014.91
7.3.60.0080.01314.86
7.3.50.0110.00814.75
7.3.40.0120.00814.70
7.3.30.0100.01114.61
7.3.20.0310.01014.60
7.3.10.0060.01614.89
7.3.00.0030.01814.70
7.2.330.0100.01016.71
7.2.320.0070.01016.75
7.2.310.0030.01316.79
7.2.300.0070.01016.79
7.2.290.0130.00416.75
7.2.230.0110.01114.84
7.2.220.0090.01115.20
7.2.210.0040.01715.20
7.2.200.0120.00915.23
7.2.190.0100.01015.18
7.2.180.0050.01115.10
7.2.170.0100.01214.92
7.2.160.0100.00915.09
7.2.150.0100.01015.25
7.2.140.0120.00915.00
7.2.130.0070.01115.26
7.2.120.0060.01215.23
7.2.110.0190.00415.12
7.2.100.0150.00615.13
7.2.90.0060.01514.90
7.2.80.0160.00615.08
7.2.70.0040.01715.00
7.2.60.0030.01715.05
7.2.50.0140.00315.27
7.2.40.0120.00615.32
7.2.30.0030.01615.32
7.2.20.0120.00915.26
7.2.10.0100.00714.97
7.2.00.0100.00615.11
7.1.320.0030.01613.83
7.1.310.0120.00914.03
7.1.300.0100.01013.98
7.1.290.0050.01413.88
7.1.280.0140.00714.04
7.1.270.0120.00814.15
7.1.260.0100.01013.80
7.1.250.0060.01213.83

preferences:
112.33 ms | 1514 KiB | 5 Q