3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getusername($user) { return 'genericUser'; } function test ($user) { { // original question $usernameA = $user ?: getusername($user); echo '$usernameA = ', var_export($usernameA, true), PHP_EOL; } { // equivalent if( $user ) { $usernameB = $user; } else { $usernameB = getusername($user); } echo '$usernameB = ', var_export($usernameB, true), PHP_EOL; } } $testCases = array('someUser', true, '', null, false, 0, @$undefined); foreach ( $testCases as $testCase ) { echo 'test with ', var_export($testCase , true) ,' ...', PHP_EOL; test($testCase); echo 'test with ', var_export($testCase , true) ,' DONE.', PHP_EOL; echo 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.4.20.0090.00019.60
8.4.10.0130.00719.51
8.3.140.0040.00417.34
8.3.130.0070.00718.66
8.3.120.0090.00918.88
8.3.110.0040.00420.94
8.3.100.0070.00316.64
8.3.90.0000.00826.77
8.3.80.0030.00616.75
8.3.70.0100.00618.43
8.3.60.0090.00616.75
8.3.50.0110.01022.11
8.3.40.0070.00719.02
8.3.30.0120.00618.75
8.3.20.0040.00421.95
8.3.10.0040.00421.63
8.3.00.0040.00419.26
8.2.260.0070.01116.97
8.2.250.0060.00316.65
8.2.240.0070.01119.01
8.2.230.0050.00522.58
8.2.220.0060.00324.06
8.2.210.0040.00426.77
8.2.200.0030.00617.00
8.2.190.0070.00716.58
8.2.180.0090.00618.29
8.2.170.0100.00619.07
8.2.160.0070.00722.96
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0080.00022.11
8.2.110.0080.00921.54
8.2.100.0040.00718.19
8.2.90.0000.00818.33
8.2.80.0030.00517.97
8.2.70.0080.00018.04
8.2.60.0040.00418.22
8.2.50.0050.00318.10
8.2.40.0000.00720.55
8.2.30.0040.00419.24
8.2.20.0000.00718.06
8.2.10.0040.00418.05
8.2.00.0000.00717.69
8.1.310.0090.00620.34
8.1.300.0060.00318.39
8.1.290.0050.00518.88
8.1.280.0070.01125.92
8.1.270.0050.00321.89
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0100.00020.45
8.1.230.0080.00320.85
8.1.220.0060.00317.74
8.1.210.0030.00618.77
8.1.200.0000.01117.35
8.1.190.0030.00617.22
8.1.180.0060.00318.10
8.1.170.0040.00418.90
8.1.160.0000.00718.82
8.1.150.0000.00820.15
8.1.140.0040.00419.60
8.1.130.0000.00717.38
8.1.120.0030.00317.52
8.1.110.0060.00317.38
8.1.100.0000.00817.48
8.1.90.0050.00217.37
8.1.80.0000.00817.50
8.1.70.0050.00317.36
8.1.60.0000.00917.49
8.1.50.0040.00417.41
8.1.40.0000.00817.52
8.1.30.0080.00017.49
8.1.20.0000.00817.66
8.1.10.0040.00417.48
8.1.00.0040.00417.50
8.0.300.0000.00719.84
8.0.290.0040.00416.88
8.0.280.0050.00318.34
8.0.270.0030.00317.14
8.0.260.0000.00616.89
8.0.250.0030.00316.92
8.0.240.0040.00416.89
8.0.230.0030.00317.04
8.0.220.0000.00816.96
8.0.210.0070.00016.90
8.0.200.0040.00416.91
8.0.190.0030.00616.96
8.0.180.0040.00416.95
8.0.170.0000.00717.03
8.0.160.0080.00016.93
8.0.150.0040.00416.78
8.0.140.0040.00417.00
8.0.130.0060.00013.41
8.0.120.0000.00716.95
8.0.110.0050.00216.91
8.0.100.0040.00416.84
8.0.90.0000.00717.03
8.0.80.0090.00617.00
8.0.70.0040.00417.02
8.0.60.0000.00717.03
8.0.50.0040.00416.89
8.0.30.0120.00517.11
8.0.20.0140.00917.35
8.0.10.0100.01017.24
8.0.00.0100.01017.04
7.4.330.0060.00216.20
7.4.320.0060.00016.52
7.4.300.0030.00316.50
7.4.290.0050.00316.51
7.4.280.0070.00016.50
7.4.270.0000.00716.60
7.4.260.0070.00316.61
7.4.250.0000.00816.50
7.4.240.0040.00416.46
7.4.230.0040.00316.37
7.4.220.0120.00616.45
7.4.210.0070.01016.57
7.4.200.0000.00716.60
7.4.160.0080.01016.54
7.4.150.0090.01516.90
7.4.140.0100.01017.30
7.4.130.0100.01116.51
7.4.120.0100.01316.53
7.4.110.0080.01116.51
7.4.100.0100.00916.51
7.4.90.0110.01216.49
7.4.80.0120.00617.41
7.4.70.0110.00816.51
7.4.60.0150.00416.49
7.4.50.0090.01216.38
7.4.40.0090.00916.40
7.4.30.0110.00916.61
7.4.20.0100.01216.61
7.4.10.0140.00516.48
7.4.00.0080.00916.08
7.3.330.0030.00313.25
7.3.320.0030.00313.46
7.3.310.0000.00616.38
7.3.300.0030.00316.43
7.3.290.0030.00316.44
7.3.280.0110.00816.40
7.3.270.0090.01016.87
7.3.260.0120.00816.52
7.3.250.0120.00716.52
7.3.240.0080.01216.53
7.3.230.0130.00516.40
7.3.220.0140.00416.42
7.3.210.0140.00816.40
7.3.200.0100.00917.40
7.3.190.0060.01216.36
7.3.180.0070.01116.53
7.3.170.0090.00916.40
7.3.160.0100.00816.45
7.3.150.0100.00816.48
7.3.140.0100.00716.34
7.3.130.0130.00916.43
7.3.120.0100.01116.48
7.3.110.0110.00716.50
7.3.100.0090.01016.43
7.3.90.0100.00916.36
7.3.80.0070.01216.38
7.3.70.0110.00716.35
7.3.60.0110.00816.48
7.3.50.0100.00816.42
7.3.40.0040.01416.48
7.3.30.0100.00816.49
7.3.20.0110.00716.47
7.3.10.0110.00616.44
7.3.00.0090.00816.44
7.2.340.0130.01416.66
7.2.330.0210.00716.59
7.2.320.0210.00516.61
7.2.310.0120.01316.63
7.2.300.0180.01016.48
7.2.290.0190.00816.68
7.2.280.0240.00716.54
7.2.270.0180.00816.46
7.2.260.0250.00716.63
7.2.250.0120.01516.58
7.2.240.0190.01116.44
7.2.230.0240.00716.58
7.2.220.0250.00716.54
7.2.210.0190.00916.59
7.2.200.0230.00416.53
7.2.190.0210.00816.57
7.2.180.0190.00716.58
7.2.170.0160.01216.55
7.2.160.0260.00316.42
7.2.150.0180.00816.57
7.2.140.0220.00516.69
7.2.130.0170.00716.83
7.2.120.0180.00816.56
7.2.110.0130.01116.73
7.2.100.0140.00816.78
7.2.90.0170.00616.65
7.2.80.0150.00616.55
7.2.70.0140.00816.72
7.2.60.0120.00816.81
7.2.50.0210.00816.74
7.2.40.0140.01016.74
7.2.30.0170.00717.38
7.2.20.0140.01018.36
7.2.10.0120.01118.24
7.2.00.0150.00918.29
7.1.330.0190.00715.40
7.1.320.0190.00915.53
7.1.310.0200.00615.57
7.1.300.0200.00615.46
7.1.290.0200.00715.36
7.1.280.0270.00515.47
7.1.270.0190.01015.47
7.1.260.0140.01315.55
7.1.250.0140.00815.55
7.1.240.0210.01015.44
7.1.230.0170.00915.38
7.1.220.0110.01415.50
7.1.210.0230.00515.41
7.1.200.0130.00815.58
7.1.190.0250.00515.34
7.1.180.0230.00615.53
7.1.170.0250.00715.45
7.1.160.0180.00715.47
7.1.150.0210.00716.34
7.1.140.0140.01217.55
7.1.130.0120.01217.51
7.1.120.0120.01317.18
7.1.110.0190.00916.81
7.1.100.0080.01316.74
7.1.90.0140.00816.81
7.1.80.0140.01016.84
7.1.70.0120.00916.40
7.1.60.0230.00923.65
7.1.50.0250.01425.09
7.1.40.0280.00925.06
7.1.30.0280.01424.92
7.1.20.0250.01525.03
7.1.10.0130.01917.31
7.1.00.0130.02217.42
7.0.330.0190.00615.12
7.0.320.0200.00415.17
7.0.310.0190.00815.05
7.0.300.0160.01115.18
7.0.290.0560.01516.05
7.0.280.0200.00716.07
7.0.270.0140.00917.10
7.0.260.0120.01016.85
7.0.250.0160.00916.41
7.0.240.0140.00816.42
7.0.230.0130.01116.44
7.0.220.0160.00716.32
7.0.210.0140.00915.98
7.0.200.0170.01016.12
7.0.190.0140.01216.00
7.0.180.0140.01215.71
7.0.170.0140.01115.71
7.0.160.0130.01215.71
7.0.150.0140.01015.73
7.0.140.0130.01816.94
7.0.130.0140.01817.04
7.0.120.0170.01916.97
7.0.110.0140.02217.00
7.0.100.0110.01916.89
7.0.90.0110.02117.05
7.0.80.0140.01717.07
7.0.70.0100.02116.92
7.0.60.0160.01916.79
7.0.50.0150.02317.08
7.0.40.0160.02016.70
7.0.30.0100.02016.79
7.0.20.0100.02116.94
7.0.10.0170.01617.00
7.0.00.0100.01917.07
5.6.400.0200.00815.67
5.6.390.0150.01415.60
5.6.380.0160.01115.82
5.6.370.0160.01115.82
5.6.360.0160.01515.73
5.6.350.0160.01315.89
5.6.340.0160.01215.74
5.6.330.0180.01115.81
5.6.320.0170.01015.97
5.6.310.0170.01115.77
5.6.300.0210.04118.33
5.6.290.0190.04418.77
5.6.280.0180.04218.79
5.6.270.0170.04618.94
5.6.260.0180.04418.92
5.6.250.0160.04618.89
5.6.240.0180.04718.86
5.6.230.0170.04518.79
5.6.220.0180.04818.79
5.6.210.0190.04518.85
5.6.200.0190.05018.84
5.6.190.0160.05118.89
5.6.180.0180.04318.89
5.6.170.0190.03818.72
5.6.160.0170.04118.74
5.6.150.0160.04618.79
5.6.140.0170.04718.82
5.6.130.0190.04218.87
5.6.120.0170.04318.82
5.6.110.0180.05218.88
5.6.100.0160.05518.72
5.6.90.0160.04818.78
5.6.80.0150.04418.45
5.6.70.0150.04318.42
5.6.60.0130.04418.38
5.6.50.0150.04018.33
5.6.40.0170.04018.39
5.6.30.0180.04818.38
5.6.20.0150.04818.39
5.6.10.0160.05218.40
5.6.00.0140.04718.41

preferences:
81.16 ms | 403 KiB | 5 Q