3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('America/New_York'); function findInvestment($invest, $interest, $years) { // calculate the future value $future_value = $invest; for ($i = 1; $i <= $years; $i++) { $future_value = ($future_value + ($future_value * $interest *.01)); } // apply currency and percent formatting $investment_f = '$'.number_format($invest, 2); $yearly_rate_f = $interest.'%'; $future_value_f = '$'.number_format($future_value, 2); print(" <label>Investment Amount:</label> <span>$investment_f</span><br> <label>Yearly Interest Rate:</label> <span>$yearly_rate_f</span><br> <label>Number of Years:</label> <span>$years</span><br> <label>Future Value:</label> <span>$future_value_f</span><br> <h4>This calculation was done on " . date("m/d/Y").". "); } function printForm($print, $invest, $interest, $years) { if ($print == TRUE) { $invest = ""; $interest = ""; $years = ""; } else { if ( strlen($invest) == 0 ) { $error_message[] = 'Investment is a required field.'; } else if ( !is_numeric($invest) ) { $error_message[] = 'Investment must be a valid number.'; $invest = ""; } else if ( $invest <= 0 ) { $error_message[] = 'Investment must be greater than zero.'; } elseif ( strlen($interest) == 0 ) { $error_message[] = 'Interest rate is a required field.'; } else if ( !is_numeric($interest) ) { $error_message[] = 'Interest rate must be a valid number.'; $interest = ""; } else if ( $interest <= 0 OR $interest > 15 ) { $error_message[] = 'Interest rate must be greater than zero and less than or equal to 15.'; } elseif ( strlen($years) == 0 ) { $error_message[] = 'Years is a required field.'; } else if ( !is_numeric($years) ) { $error_message[] = 'Years must be a valid number.'; $years = ""; } else if ( $years <= 0 OR $years > 50 ) { $error_message[] = 'Years must be greater than zero and less than or equal to 50.'; } // set error message to empty string if no invalid entries else { $printResults = 1; $error_message = ''; } } print(" <!DOCTYPE html> <html> <head> <title>Future Value Calculator</title> <link href=\"main.css\" rel=\"stylesheet\" type=\"text/css\"> <meta charset=\"utf-8\"> </head> <body> <div id=\"content\"> <h1>Future Value Calculator</h1>"); if (!empty($error_message)) { foreach($error_message as $msg) { print("<p class=\"error\">$msg</p>"); } } else { $invest = ""; $interest = ""; $years = ""; } print("<form action=\"index.php\" method=\"post\"> <div id=\"data\"> <label>Investment Amount:</label> <input type=\"text\" name=\"investment\" value=\"$invest\"><br> <label class=\"clear\">Yearly Interest Rate:</label> <input type=\"text\" name=\"interest_rate\" value=\"$interest\"><br> <label class=\"clear\">Number of Years:</label> <input type=\"text\" name=\"years\" value=\"$years\"><br> </div> <div id=\"buttons\"> <label class=\"clear\">&nbsp;</label> <input type=\"submit\" value=\"Calculate\" name=\"submit\"><br> </div> </form>"); if (!empty($_POST['submit']) AND !$error_message) { findInvestment($_POST['investment'], $_POST['interest_rate'], $_POST['years']); } print("</div> </body> </html> "); } //if (empty($_POST['investment']) && empty($_POST['interest_rate']) && empty($_POST['years'])) { // printForm(1, "", "", ""); //} if (!empty($_POST['submit'])) { printForm(0, $_POST['investment'], $_POST['interest_rate'], $_POST['years']); } else { printForm(1, "", "", ""); } ?>

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.3.60.0120.00318.43
8.3.50.0080.00821.97
8.3.40.0070.01018.70
8.3.30.0090.01220.35
8.3.20.0000.00820.34
8.3.10.0040.00422.10
8.3.00.0100.00722.39
8.2.180.0070.01116.63
8.2.170.0140.00322.96
8.2.160.0140.00020.57
8.2.150.0040.00424.18
8.2.140.0150.00024.66
8.2.130.0040.00426.16
8.2.120.0050.00319.58
8.2.110.0100.00021.06
8.2.100.0060.00617.84
8.2.90.0050.00319.36
8.2.80.0030.00517.97
8.2.70.0000.00817.50
8.2.60.0040.00417.93
8.2.50.0030.00818.10
8.2.40.0030.00618.22
8.2.30.0020.00518.18
8.2.20.0040.00417.81
8.2.10.0030.00517.80
8.2.00.0070.00317.68
8.1.280.0040.01125.92
8.1.270.0080.00024.66
8.1.260.0090.00626.35
8.1.250.0040.00428.09
8.1.240.0060.00324.02
8.1.230.0080.00317.82
8.1.220.0030.00517.89
8.1.210.0000.00818.77
8.1.200.0030.00717.48
8.1.190.0000.00817.35
8.1.180.0050.00318.10
8.1.170.0040.00418.50
8.1.160.0070.00022.11
8.1.150.0040.00418.64
8.1.140.0040.00417.57
8.1.130.0030.00317.94
8.1.120.0000.00717.58
8.1.110.0000.00717.46
8.1.100.0030.00617.49
8.1.90.0070.00017.55
8.1.80.0040.00417.65
8.1.70.0000.00717.55
8.1.60.0030.00617.55
8.1.50.0000.00817.54
8.1.40.0040.00417.49
8.1.30.0040.00417.59
8.1.20.0040.00417.70
8.1.10.0030.00617.58
8.1.00.0000.00817.44
8.0.300.0030.00618.77
8.0.290.0040.00416.75
8.0.280.0070.00018.42
8.0.270.0030.00317.34
8.0.260.0040.00416.89
8.0.250.0000.00716.98
8.0.240.0060.00317.00
8.0.230.0070.00017.05
8.0.220.0040.00416.87
8.0.210.0000.00716.93
8.0.200.0040.00417.09
8.0.190.0080.00016.93
8.0.180.0000.00717.04
8.0.170.0000.00816.89
8.0.160.0040.00416.90
8.0.150.0000.00717.02
8.0.140.0000.00716.93
8.0.130.0050.00013.38
8.0.120.0040.00416.82
8.0.110.0030.00516.93
8.0.100.0040.00416.94
8.0.90.0040.00416.79
8.0.80.0120.00916.95
8.0.70.0000.00716.90
8.0.60.0000.00716.79
8.0.50.0000.00716.82
8.0.30.0120.00717.28
8.0.20.0090.00917.40
8.0.10.0000.00717.21
8.0.00.0140.00616.95
7.4.330.0030.00315.00
7.4.320.0030.00316.71
7.4.300.0000.00616.63
7.4.290.0030.00316.64
7.4.280.0000.00716.46
7.4.270.0030.00316.52
7.4.260.0050.00216.51
7.4.250.0050.00316.62
7.4.240.0020.00516.53
7.4.230.0070.00016.78
7.4.220.0070.01016.69
7.4.210.0080.00716.55
7.4.200.0000.00716.55
7.4.190.0000.00816.52
7.4.160.0110.00616.53
7.4.150.0110.00717.40
7.4.140.0150.00717.86
7.4.130.0030.01416.59
7.4.120.0150.00516.63
7.4.110.0040.01516.34
7.4.100.0120.01216.65
7.4.90.0080.01616.63
7.4.80.0030.01419.39
7.4.70.0130.00716.48
7.4.60.0170.00616.30
7.4.50.0040.00416.51
7.4.40.0070.00722.77
7.4.30.0050.01116.55
7.4.10.0030.01614.82
7.4.00.0060.01114.92
7.3.330.0030.00313.26
7.3.320.0050.00013.35
7.3.310.0020.00516.52
7.3.300.0050.00216.38
7.3.290.0030.01116.34
7.3.280.0120.00516.42
7.3.270.0000.01717.40
7.3.260.0070.01016.67
7.3.250.0090.01016.59
7.3.240.0100.00716.70
7.3.230.0110.00716.63
7.3.210.0160.00016.62
7.3.200.0200.00019.39
7.3.190.0130.00916.71
7.3.180.0120.00916.77
7.3.170.0100.00716.34
7.3.160.0090.00916.48
7.3.130.0030.01614.80
7.3.120.0060.01015.04
7.3.110.0070.01215.05
7.3.100.0040.01114.95
7.3.90.0090.00714.93
7.3.80.0110.00314.90
7.3.70.0080.01014.76
7.3.60.0020.01214.93
7.3.50.0060.00614.80
7.3.40.0090.00314.68
7.3.30.0100.00314.64
7.3.20.0060.01116.57
7.3.10.0030.01216.46
7.3.00.0070.00916.55
7.2.330.0070.01116.72
7.2.320.0100.00816.93
7.2.310.0110.00616.75
7.2.300.0100.00716.82
7.2.290.0060.01016.65
7.2.260.0040.01514.64
7.2.250.0100.00914.87
7.2.240.0060.01115.09
7.2.230.0040.01114.90
7.2.220.0080.00515.12
7.2.210.0050.00914.66
7.2.200.0050.00714.86
7.2.190.0060.00714.98
7.2.180.0050.01114.88
7.2.170.0040.01214.62
7.2.160.0150.00415.07
7.2.150.0110.00716.93
7.2.140.0040.00816.73
7.2.130.0000.01416.80
7.2.120.0030.00616.89
7.2.110.0120.00516.70
7.2.100.0040.00816.91
7.2.90.0130.00316.65
7.2.80.0030.01317.04
7.2.70.0030.01016.94
7.2.60.0030.00816.76
7.2.50.0030.00616.90
7.2.40.0030.01216.51
7.2.30.0030.00616.63
7.2.20.0060.00916.84
7.2.10.0000.01316.70
7.2.00.0070.00316.98
7.1.330.0020.01215.51
7.1.320.0050.00515.87
7.1.310.0060.00615.81
7.1.300.0100.00515.78
7.1.290.0050.01015.60
7.1.280.0050.00915.72
7.1.270.0060.00715.77
7.1.260.0070.00715.73
7.1.250.0080.00415.80
7.1.240.0060.01015.84
7.1.230.0040.01015.74
7.1.220.0030.01215.63
7.1.210.0080.00415.39
7.1.200.0080.00615.68
7.1.190.0030.01215.85
7.1.180.0070.00715.83
7.1.170.0030.01015.62
7.1.160.0030.00615.79
7.1.150.0100.00315.81
7.1.140.0110.00415.68
7.1.130.0030.01015.71
7.1.120.0100.00615.79
7.1.110.0070.00715.63
7.1.100.0100.00315.72
7.1.90.0030.00915.51
7.1.80.0030.01015.63
7.1.70.0070.00616.24
7.1.60.0100.00817.68
7.1.50.0000.01216.10
7.1.40.0070.00715.64
7.1.30.0060.00615.79
7.1.20.0000.01115.45
7.1.10.0060.00615.48
7.1.00.0040.02118.98
7.0.330.0120.00015.18
7.0.320.0000.00815.34
7.0.310.0100.00015.37
7.0.300.0070.01015.08
7.0.290.0060.00915.43
7.0.280.0040.00715.18
7.0.270.0000.00915.48
7.0.260.0000.01615.24
7.0.250.0000.01315.46
7.0.240.0070.00415.19
7.0.230.0100.00315.30
7.0.220.0040.01115.01
7.0.210.0000.01415.07
7.0.200.0030.00715.78
7.0.190.0040.00815.35
7.0.180.0080.00015.11
7.0.170.0030.01315.28
7.0.160.0070.01115.38
7.0.150.0030.00715.22
7.0.140.0020.04118.75
7.0.130.0140.00014.98
7.0.120.0060.01015.36
7.0.110.0060.01115.44
7.0.100.0060.00615.37
7.0.90.0040.00415.52
7.0.80.0050.03117.69
7.0.70.0100.04517.68
7.0.60.0120.03917.63
7.0.50.0060.05017.99
7.0.40.0070.04816.65
7.0.30.0130.03016.67
7.0.20.0050.04916.60
7.0.10.0070.03816.71
7.0.00.0100.04316.76
5.6.400.0070.01014.44
5.6.390.0040.00714.15
5.6.380.0060.01014.50
5.6.370.0030.01014.11
5.6.360.0100.00614.07
5.6.350.0100.00314.24
5.6.340.0000.01414.34
5.6.330.0030.00614.43
5.6.320.0070.00714.05
5.6.310.0000.01314.42
5.6.300.0030.01014.45
5.6.290.0070.00714.13
5.6.280.0120.03317.66
5.6.270.0000.01914.20
5.6.260.0030.01414.37
5.6.250.0060.00914.08
5.6.240.0070.00714.31
5.6.230.0170.04017.49
5.6.220.0130.03517.39
5.6.210.0100.02317.55
5.6.200.0050.03517.68
5.6.190.0130.03517.72
5.6.180.0080.03217.58
5.6.170.0050.04917.71
5.6.160.0100.04017.74
5.6.150.0070.04017.64
5.6.140.0030.04617.73
5.6.130.0020.04617.72
5.6.120.0100.03017.63
5.6.110.0070.04617.52
5.6.100.0080.03517.61
5.6.90.0120.04217.55
5.6.80.0050.04517.45
5.6.70.0030.04317.23
5.6.60.0080.04117.31
5.6.50.0030.04717.44
5.6.40.0060.04617.36
5.6.30.0070.03917.13
5.6.20.0120.01817.32
5.6.10.0030.02517.28
5.6.00.0050.02217.21
5.5.380.0060.00914.55
5.5.370.0100.04217.45
5.5.360.0080.04117.12
5.5.350.0130.04417.54
5.5.340.0080.04417.44
5.5.330.0070.04717.73
5.5.320.0080.04517.47
5.5.310.0060.04217.59
5.5.300.0080.04517.56
5.5.290.0100.04217.56
5.5.280.0050.02617.55
5.5.270.0060.04817.64
5.5.260.0170.03617.52
5.5.250.0080.04217.56
5.5.240.0070.03017.25
5.5.230.0120.03517.20
5.5.220.0100.02717.23
5.5.210.0030.04217.17
5.5.200.0090.03717.18
5.5.190.0030.03517.13
5.5.180.0050.03717.17
5.5.170.0080.00814.17
5.5.160.0110.02317.15
5.5.150.0050.04217.13
5.5.140.0090.01717.10
5.5.130.0070.02317.21
5.5.120.0040.03717.18
5.5.110.0070.02217.19
5.5.100.0050.02417.13
5.5.90.0070.02517.18
5.5.80.0060.02317.09
5.5.70.0060.02117.06
5.5.60.0060.03317.18
5.5.50.0070.03317.21
5.5.40.0030.02817.14
5.5.30.0030.02717.14
5.5.20.0110.02016.98
5.5.10.0060.02917.17
5.5.00.0090.03217.25
5.4.450.0080.04216.05
5.4.440.0090.03916.10
5.4.430.0070.03816.01
5.4.420.0030.04615.98
5.4.410.0020.04815.89
5.4.400.0040.03215.94
5.4.390.0080.03615.95
5.4.380.0020.04615.91
5.4.370.0000.04515.91
5.4.360.0070.04315.88
5.4.350.0090.04015.92
5.4.340.0090.03315.87
5.4.330.0000.01312.72
5.4.320.0090.02015.96
5.4.310.0050.02315.93
5.4.300.0080.02115.89
5.4.290.0060.02215.95
5.4.280.0080.03715.92
5.4.270.0050.02815.96
5.4.260.0040.02215.80
5.4.250.0020.02815.92
5.4.240.0040.02215.96
5.4.230.0030.02815.79
5.4.220.0050.02315.92
5.4.210.0030.02415.93
5.4.200.0050.02315.95
5.4.190.0000.02815.87
5.4.180.0040.02315.93
5.4.170.0030.02315.87
5.4.160.0050.02815.82
5.4.150.0120.02315.86
5.4.140.0040.02014.63
5.4.130.0030.02214.59
5.4.120.0050.02014.60
5.4.110.0020.02314.56
5.4.100.0060.02314.60
5.4.90.0070.01714.55
5.4.80.0020.02114.63
5.4.70.0050.02414.62
5.4.60.0060.02814.57
5.4.50.0050.01914.59
5.4.40.0090.02714.62
5.4.30.0020.02714.56
5.4.20.0050.03214.49
5.4.10.0070.01814.55
5.4.00.0020.02214.21
5.3.290.0060.02413.78
5.3.280.0060.02913.63
5.3.270.0110.01713.70
5.3.260.0090.01813.66
5.3.250.0040.02413.72
5.3.240.0030.02213.68
5.3.230.0030.02513.68
5.3.220.0100.03713.62
5.3.210.0090.01713.69
5.3.200.0060.01813.68
5.3.190.0050.02213.62
5.3.180.0050.02713.64
5.3.170.0060.02013.61
5.3.160.0030.02313.67
5.3.150.0030.02613.62
5.3.140.0070.02013.69
5.3.130.0050.01813.70
5.3.120.0020.02213.72
5.3.110.0030.04513.71
5.3.100.0030.02813.41
5.3.90.0020.02913.43
5.3.80.0070.03713.34
5.3.70.0060.03713.37
5.3.60.0080.01813.36
5.3.50.0050.02913.38
5.3.40.0020.02613.38
5.3.30.0050.02613.39
5.3.20.0020.02313.28
5.3.10.0010.02313.21
5.3.00.0050.04013.26
5.2.170.0030.03011.46
5.2.160.0030.02711.46
5.2.150.0100.02311.46
5.2.140.0000.03311.46
5.2.130.0000.03011.46
5.2.120.0030.05311.46
5.2.110.0100.06011.46
5.2.100.0030.06011.46
5.2.90.0030.06011.46
5.2.80.0030.06311.46
5.2.70.0100.06011.46
5.2.60.0100.06011.46
5.2.50.0130.05311.46
5.2.40.0000.06711.46
5.2.30.0030.05011.46
5.2.20.0100.04711.46
5.2.10.0100.05011.46
5.2.00.0030.06011.46
5.1.60.0030.04311.46
5.1.50.0070.03711.46
5.1.40.0030.05711.46
5.1.30.0030.05711.46
5.1.20.0130.04711.46
5.1.10.0030.06311.46
5.1.00.0100.05011.46
5.0.50.0030.04711.46
5.0.40.0000.03011.46
5.0.30.0030.06011.46
5.0.20.0030.04711.46
5.0.10.0030.04311.46
5.0.00.0070.06011.46
4.4.90.0030.03011.46
4.4.80.0030.03011.46
4.4.70.0000.03711.46
4.4.60.0000.04011.46
4.4.50.0000.03711.46
4.4.40.0000.05711.46
4.4.30.0030.03311.46
4.4.20.0000.02711.46
4.4.10.0000.04011.46
4.4.00.0000.05711.46
4.3.110.0030.02311.46
4.3.100.0030.03311.46
4.3.90.0030.03711.46
4.3.80.0030.04711.46
4.3.70.0000.03311.46
4.3.60.0030.03011.46
4.3.50.0030.03311.46
4.3.40.0030.04011.46
4.3.30.0000.02011.46
4.3.20.0000.02011.46
4.3.10.0000.03711.46
4.3.00.0030.03711.46

preferences:
39.9 ms | 401 KiB | 5 Q