3v4l.org

run code in 300+ PHP versions simultaneously
<?php function maybe_change_user_language( $selected_lang, $user_lang, $site_lang ) { if ( $selected_lang !== $site_lang ) { $user_lang = $selected_lang; } return $user_lang; } // Tests - Scroll to the bottom for results. function test_respect_user_language_preference( $expected, $site_lang, $user_lang, $selected_lang = 'English' ) { $user_lang = maybe_change_user_language( $selected_lang, $user_lang, $site_lang ); echo 'Expected: ', $expected, PHP_EOL; echo 'Actual: ', $user_lang, PHP_EOL; return 'Result: ' . ( $expected === $user_lang ? 'Pass' : 'Fail' ); } $tests = array( 'defaults with nothing selected' => array( 'expected' => 'English', 'site_lang' => 'English', 'user_lang' => 'English', 'selected_lang' => 'English', ), 'no existing preference and selects Spanish' => array( 'expected' => 'Spanish', 'site_lang' => 'English', 'user_lang' => 'English', 'selected_lang' => 'Spanish', ), 'already prefers Spanish and selects Spanish' => array( 'expected' => 'Spanish', 'site_lang' => 'English', 'user_lang' => 'Spanish', 'selected_lang' => 'Spanish', ), 'already prefers Spanish and selects nothing' => array( 'expected' => 'Spanish', 'site_language' => 'English', 'user_lang' => 'Spanish', 'selected_lang' => 'English', ), ); foreach ( $tests as $test => $args ) { $sep = str_pad( '', strlen( $test ), '=' ); echo $sep, PHP_EOL, $test, PHP_EOL, $sep, PHP_EOL; echo test_respect_user_language_preference( ...array_values( $args ) ), PHP_EOL, 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.0040.01819.72
8.4.10.0040.00417.57
8.3.150.0040.00418.36
8.3.140.0100.01019.18
8.3.130.0050.00518.60
8.3.120.0000.00918.92
8.3.110.0080.00820.94
8.3.100.0040.00418.28
8.3.90.0050.00326.77
8.3.80.0040.00418.54
8.3.70.0070.00716.62
8.3.60.0120.00916.49
8.3.50.0100.00719.79
8.3.40.0100.00320.22
8.3.30.0060.00918.50
8.3.20.0040.00424.18
8.3.10.0000.00824.66
8.3.00.0040.00426.16
8.2.260.0040.00416.48
8.2.250.0080.00018.31
8.2.240.0030.00616.92
8.2.230.0090.00022.58
8.2.220.0040.00824.06
8.2.210.0120.00326.77
8.2.200.0090.00318.29
8.2.190.0120.00616.63
8.2.180.0040.01425.92
8.2.170.0100.01018.79
8.2.160.0110.00422.96
8.2.150.0000.00725.66
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0000.00819.54
8.2.110.0070.00320.56
8.2.100.0080.00417.91
8.2.90.0050.00318.97
8.2.80.0030.00618.03
8.2.70.0000.00917.63
8.2.60.0000.00817.63
8.2.50.0060.00618.10
8.2.40.0000.00818.34
8.2.30.0110.00018.00
8.2.20.0040.00420.45
8.2.10.0030.00517.81
8.2.00.0000.00819.19
8.1.310.0110.00718.45
8.1.300.0000.00917.56
8.1.290.0040.00730.84
8.1.280.0110.00425.92
8.1.270.0150.00023.99
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0030.00623.82
8.1.230.0090.00320.88
8.1.220.0080.00017.78
8.1.210.0060.00318.77
8.1.200.0030.00717.48
8.1.190.0080.00017.53
8.1.180.0070.00718.10
8.1.170.0030.00618.51
8.1.160.0070.00018.81
8.1.150.0000.00718.64
8.1.140.0040.00417.32
8.1.130.0080.00018.95
8.1.120.0000.00717.48
8.1.110.0040.00417.46
8.1.100.0040.00417.34
8.1.90.0000.00717.35
8.1.80.0000.00717.34
8.1.70.0030.00317.30
8.1.60.0030.00617.62
8.1.50.0030.00617.53
8.1.40.0120.00417.50
8.1.30.0000.00817.53
8.1.20.0000.00817.54
8.1.10.0190.00517.34
8.1.00.0120.00017.21
8.0.300.0040.00418.77
8.0.290.0040.00416.75
8.0.280.0080.00020.17
8.0.270.0030.00519.76
8.0.260.0000.00718.51
8.0.250.0070.00016.97
8.0.240.0040.00416.93
8.0.230.0050.00217.00
8.0.220.0030.00316.93
8.0.210.0050.00316.92
8.0.200.0030.00317.00
8.0.190.0030.00516.95
8.0.180.0000.00716.89
8.0.170.0030.00516.95
8.0.160.0080.00016.91
8.0.150.0000.00816.91
8.0.140.0030.01116.79
8.0.130.0070.00516.87
8.0.120.0040.00916.82
8.0.110.0080.00416.79
8.0.100.0090.00616.64
8.0.90.0040.00816.74
8.0.80.0110.00016.74
8.0.70.0110.00016.79
8.0.60.0070.00716.82
8.0.50.0080.00416.77
8.0.30.0130.00316.88
8.0.20.0060.00616.88
8.0.10.0070.00316.89
7.4.330.0060.00015.55
7.4.320.0000.00616.48
7.4.300.0060.00016.52
7.4.290.0000.00816.42
7.4.280.0000.00816.61
7.4.270.0070.00616.42
7.4.260.0000.01116.34
7.4.250.0140.00016.35
7.4.240.0040.00816.30
7.4.230.0040.00916.48
7.4.220.0120.00416.41
7.4.210.0100.00316.49
7.4.200.0100.00516.46
7.4.190.0050.00516.57
7.4.180.0110.00316.48
7.4.160.0100.00316.50
7.4.150.0110.00816.35
7.4.140.0190.00016.31
7.4.130.0150.00316.29
7.4.120.0150.00316.36
7.4.110.0180.00016.50
7.4.100.0180.00016.38
7.4.90.0140.00516.39
7.4.80.0150.00316.29
7.4.70.0120.00616.44
7.4.60.0130.00616.38
7.4.50.0090.00916.32
7.4.40.0120.00616.39
7.4.30.0100.00716.45
7.4.20.0120.00516.32
7.4.10.0160.00316.23
7.4.00.0090.00916.42

preferences:
33.75 ms | 403 KiB | 5 Q