3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('FIELDS', ['name', 'address', 'city']); define( 'HTML_FIELD_FORM', <<<'HTML' <h2>%1$s</h2> <form method="post" autocomplete="off"> <input type="text" name="%1$s" autocomplete="off" placeholder="%1$s"><br> <input value="submit" type="submit"> </form> HTML ); define( 'HTML_CLEAR_FORM', <<<'HTML' <form method="post" autocomplete="off"> <input type="text" name="%1$s" value="1" hidden><br> <input value="%1$s" type="submit"> </form> HTML ); foreach (FIELDS as $field) { if (isset($_POST[$field])) { // Set session & cookie from post $_SESSION[$field] = $_POST[$field]; setcookie($field, $_POST[$field]); } elseif (isset($_COOKIE[$field])) { // Set session from cookie $_SESSION[$field] = $_COOKIE[$field]; } elseif (!isset($_SESSION[$field])) { // Present individual field form printf(HTML_FIELD_FORM, $field); } } foreach (['clear_session', 'clear_cookies'] as $action) { printf(HTML_CLEAR_FORM, $action); }

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.130.0110.00817.96
8.4.120.0120.00820.26
8.4.110.0080.00722.40
8.4.100.0130.00717.48
8.4.90.0130.00717.69
8.4.80.0050.00417.71
8.4.70.0120.00819.54
8.4.60.0040.00420.28
8.4.50.0110.00818.66
8.4.40.0090.00919.45
8.4.30.0190.00018.88
8.4.20.0030.00924.28
8.4.10.0070.01423.82
8.3.260.0100.00916.77
8.3.250.0070.00919.03
8.3.240.0130.01016.60
8.3.230.0030.00616.63
8.3.220.0070.01217.25
8.3.210.0130.00716.51
8.3.200.0040.00516.62
8.3.190.0050.00418.91
8.3.180.0040.00517.06
8.3.170.0060.00317.27
8.3.160.0070.01118.50
8.3.150.0110.00718.43
8.3.140.0000.00818.37
8.3.130.0130.00718.51
8.3.120.0150.00020.70
8.3.110.0030.01316.48
8.3.100.0060.00316.78
8.3.90.0000.00818.19
8.3.80.0030.00617.97
8.3.70.0160.00316.63
8.3.60.0140.00316.63
8.3.50.0140.00716.55
8.3.40.0090.00920.07
8.3.30.0220.00018.54
8.3.20.0040.00424.18
8.3.10.0040.00424.66
8.3.00.0040.00426.16
8.2.290.0060.00620.07
8.2.280.0130.00518.43
8.2.270.0130.00717.00
8.2.260.0090.00918.66
8.2.250.0060.00316.68
8.2.240.0040.00416.56
8.2.230.0120.00320.94
8.2.220.0090.00024.06
8.2.210.0080.00026.77
8.2.200.0070.00318.29
8.2.190.0110.00716.58
8.2.180.0130.00718.29
8.2.170.0180.00418.79
8.2.160.0100.00322.96
8.2.150.0070.00025.66
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0030.00521.08
8.2.110.0070.00319.21
8.2.100.0110.00718.22
8.2.90.0210.00418.26
8.2.80.0190.00518.64
8.2.70.0170.00442.63
8.2.60.0250.00518.09
8.2.50.0170.00518.62
8.2.40.0140.00519.34
8.2.30.0140.00518.60
8.2.20.0100.00618.91
8.2.10.0150.00518.61
8.2.00.0130.00618.59
8.1.330.0110.00722.15
8.1.320.0090.01217.89
8.1.310.0040.00418.06
8.1.300.0050.00518.41
8.1.290.0060.00318.88
8.1.280.0090.00925.92
8.1.270.0100.00823.31
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0060.00322.18
8.1.230.0170.00519.28
8.1.220.0150.00418.21
8.1.210.0200.00118.58
8.1.200.0170.00318.00
8.1.190.0130.00818.04
8.1.180.0150.00518.62
8.1.170.0150.00418.35
8.1.160.0150.00718.85
8.1.150.0180.00418.76
8.1.140.0110.00818.87
8.1.130.0170.00418.87
8.1.120.0170.00418.49
8.1.110.0150.00518.47
8.1.100.0170.00318.51
8.1.90.0160.00518.45
8.1.80.0160.00518.52
8.1.70.0170.00418.50
8.1.60.0180.00418.49
8.1.50.0170.00418.48
8.1.40.0160.00518.53
8.1.30.0190.00318.53
8.1.20.0170.00318.54
8.1.10.0160.00618.51
8.1.00.0180.00318.50
8.0.300.0160.00418.99
8.0.290.0220.00217.92
8.0.280.0180.00618.71
8.0.270.0150.00618.22
8.0.260.0190.00218.24
8.0.250.0140.00618.31
8.0.240.0160.00518.29
8.0.230.0160.00518.27
8.0.220.0170.00518.22
8.0.210.0170.00318.24
8.0.200.0160.00518.26
8.0.190.0170.00418.28
8.0.180.0120.00818.62
8.0.170.0150.00418.29
8.0.160.0140.00718.27
8.0.150.0140.00418.26
8.0.140.0140.00718.26
8.0.130.0150.00318.27
8.0.120.0150.00618.26
8.0.110.0160.00518.24
8.0.100.0150.00518.25
8.0.90.0140.00518.24
8.0.80.0150.00418.24
8.0.70.0130.00718.27
8.0.60.0160.00518.23
8.0.50.0150.00518.25
8.0.30.0160.00518.26
8.0.20.0170.00318.29
8.0.10.0130.00818.29

preferences:
31.09 ms | 403 KiB | 5 Q