3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set('display_errors', 'On'); error_reporting(E_ALL); session_start(); if (!isset($_SESSION['username'])) { header("location:login.php?error=1"); } elseif (!isset($_SESSION['id'])) { header("location:login.php?error=1"); } $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $start = $time; define("DB_HOST","mysql117.loopia.se"); define("DB_USER","normal@i103189"); define("DB_PASS","KungMicke87"); define("DB_NAME","indiehjaerta_com"); if (isset($_POST['add'])) { if (isset($_POST['forumid']) && (!empty($_POST['forumid']))) { if (isset($_POST['threadid']) && (!empty($_POST['threadid']))) { // Connect to MySQLi $sqli = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME) or die("Error: ".mysqli_error($sqli)); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $saveThread = TRUE; $emptyText = FALSE; $text = mysqli_real_escape_string($sqli, $_POST['text']); $fid = mysqli_real_escape_string($sqli, $_POST['forumid']); $tid = mysqli_real_escape_string($sqli, $_POST['threadid']); $query = mysqli_query($sqli,"SELECT * FROM forumcat WHERE id='$fid'") or die("Error: ".mysqli_error($sqli)); $resultsCategory = mysqli_num_rows($query); $query2 = mysqli_query($sqli,"SELECT * FROM forumtopics WHERE id='$tid'") or die("Error: ".mysqli_error($sqli)); $resultsThread = mysqli_num_rows($query2); if ($resultsCategory == 0) { $error = "No such CategoryID."; } elseif ($resultsThread == 0) { $error = "No such resultsThreadID."; } else { $timestamp = date('Y-m-d H:i:s'); $userid = $_SESSION['id']; $ip = ip2long($_SERVER['REMOTE_ADDR']); if (empty($text)) { $emptyText = TRUE; $saveThread = FALSE; } if ($saveThread == TRUE) { $addquery = mysqli_query($sqli,"INSERT INTO forumreplies (`text`, `categoryid`, 'threadid`, `userid`, `timestamp`, `ipaddress`) VALUES ('$text', '$fid', '$tid', '$userid', '$timestamp', '$ip')"); $tid = mysqli_insert_id($addquery); header("location:forummessage.php?added=thread&fid=$fid&tid=$tid"); } } } } else { // Connect to MySQLi $sqli = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME) or die("Error: ".mysqli_error($sqli)); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $saveThread = TRUE; $emptySubject = FALSE; $emptyText = FALSE; $subject = mysqli_real_escape_string($sqli, $_POST['subject']); $text = mysqli_real_escape_string($sqli, $_POST['text']); $fid = mysqli_real_escape_string($sqli, $_POST['forumid']); $query = mysqli_query($sqli,"SELECT * FROM forumcat WHERE id='$fid'") or die("Error: ".mysqli_error($sqli)); $results = mysqli_num_rows($query); if ($results == 0) { $error = "No such CategoryID."; } else { $timestamp = date('Y-m-d H:i:s'); $userid = $_SESSION['id']; $ip = ip2long($_SERVER['REMOTE_ADDR']); if (empty($subject)) { $emptySubject = TRUE; $saveThread = FALSE; } elseif (empty($text)) { $emptyText = TRUE; $saveThread = FALSE; } if ($saveThread == TRUE) { $addquery = mysqli_query($sqli,"INSERT INTO forumtopics (`threadname`, `text`, `categoryid`, `userid`, `timestamp`, `ipaddress`) VALUES ('$subject', '$text', '$fid', '$userid', '$timestamp', '$ip')"); $tid = mysqli_insert_id($addquery); header("location:forummessage.php?added=thread&fid=$fid&tid=$tid"); } } } } else { echo "No ForumID set."; } } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <title>indiehjaerta.com - Forum</title> <link href="style_test.css" rel="stylesheet" type="text/css" /> </head> <body> <a href="login.php">Login<a/> - <a href="admin.php">Admin<a/> - <a href="members.php">Members<a/> - <a href="register.php">Register<a/> - <a href="blog.php">Blog<a/> - <a href="news.php">News<a/> - <a href="event.php">Event<a/> - <a href="forum.php">Forum<a/> - <a href="logout.php">Logout<a/> <br /> <hr /> <br /> <?php if (isset($_GET['added']) && ($_GET['added'] == 'thread')) { ?> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td> <strong>Forums</strong> </td> </tr> <tr> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Thread Created</strong></td> </tr> <tr> <td colspan="3"><a href="forum.php?fid=<?php echo $_GET['fid'] ?>&tid=<?php echo $_GET['tid'] ?>" style="color: black">Link to thread.</a></td> </tr> </table> </td> </tr> </table> <?php } elseif (isset($_GET['action']) && $_GET['action'] == 'new') { if (isset($_GET['type']) && $_GET['type'] == 'thread') { if (isset($_GET['fid']) && empty(!$_GET['fid'])) { if (isset($_GET['tid']) && empty(!$_GET['tid'])) { ?> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td> <strong>Forums</strong> </td> </tr> <tr> <form method="post" action=""> <input name="forumid" type="hidden" id="forumid" value="<?php echo $_GET['fid'] ?>"> <input name="threadid" type="hidden" id="threadid" value="<?php echo $_GET['tid'] ?>"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Answer to Thread</strong></td> </tr> <tr> <td colspan="3"><?php if(isset($error)) { echo $error; } ?></td> </tr> <tr> <td width="78"><strong>Subject</strong></td> <td width="6">:</td> <td width="294"><input name="subject" type="text" id="subject" readonly></td> </tr> <tr> <td>Story</td> <td>:</td> <td><textarea name="text" type="text" id="text" rows="3"></textarea></td> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td><input type="submit" name="add" value="Post"></td> </tr> </table> </td> </form> </tr> </table> <?php } else { ?> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td> <strong>Forums</strong> </td> </tr> <tr> <form method="post" action=""> <input name="forumid" type="hidden" id="forumid" value="<?php echo $_GET['fid'] ?>"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Create Thread</strong></td> </tr> <tr> <td colspan="3"><?php if(isset($error)) { echo $error; } ?></td> </tr> <tr> <td width="78"><strong>Subject</strong></td> <td width="6">:</td> <td width="294"><input name="subject" type="text" id="subject"></td> </tr> <tr> <td>Story</td> <td>:</td> <td><textarea name="text" type="text" id="text" rows="3"></textarea></td> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td><input type="submit" name="add" value="Post"></td> </tr> </table> </td> </form> </tr> </table> <?php } } else { echo "Forum ID missing."; } } } else { echo "Nothing to see here."; } ?> <?php $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $finish = $time; $total_time = round(($finish - $start), 4); echo '<span class="text">Page generated in '.$total_time.' seconds.</span><br />'; ?> </body> </html>

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)
5.4.290.0090.04012.53
5.4.280.0130.04112.43
5.4.270.0070.04612.42
5.4.260.0110.05712.43
5.4.250.0120.05912.43
5.4.240.0080.03712.42
5.4.230.0080.04912.41
5.4.220.0080.04312.42
5.4.210.0070.04712.41
5.4.200.0110.06212.41
5.4.190.0160.06712.41
5.4.180.0100.06612.41
5.4.170.0140.04312.42
5.4.160.0080.04712.41
5.4.150.0070.04812.41
5.4.140.0090.05512.10
5.4.130.0150.06612.08
5.4.120.0070.03712.05
5.4.110.0030.04012.05
5.4.100.0060.03812.05
5.4.90.0110.03512.04
5.4.80.0070.04012.05
5.4.70.0080.04112.04
5.4.60.0090.04012.04
5.4.50.0140.05012.04
5.4.40.0070.03812.03
5.4.30.0040.04212.02
5.4.20.0110.05912.02
5.4.10.0060.04512.03
5.4.00.0080.04511.52
5.3.280.0130.04612.71
5.3.270.0080.05112.73
5.3.260.0100.05412.72
5.3.250.0080.03712.72
5.3.240.0110.03612.72
5.3.230.0070.06212.71
5.3.220.0120.03512.68
5.3.210.0130.07112.68
5.3.200.0110.06012.68
5.3.190.0090.05112.68
5.3.180.0110.05212.68
5.3.170.0080.06112.67
5.3.160.0110.07312.67
5.3.150.0060.06012.68
5.3.140.0180.06712.66
5.3.130.0080.04112.65
5.3.120.0100.03812.66
5.3.110.0100.04112.66
5.3.100.0170.08312.13
5.3.90.0130.05112.11
5.3.80.0060.04812.11
5.3.70.0090.04412.10
5.3.60.0130.03412.09
5.3.50.0070.03712.03
5.3.40.0090.03612.03
5.3.30.0110.04812.00
5.3.20.0150.05411.77
5.3.10.0080.03611.74
5.3.00.0070.04511.73
5.2.170.0040.0389.24
5.2.160.0080.0459.23
5.2.150.0040.0529.24
5.2.140.0100.0729.23
5.2.130.0060.0339.19
5.2.120.0080.0309.19
5.2.110.0090.0289.20
5.2.100.0070.0329.20
5.2.90.0060.0329.20
5.2.80.0040.0399.20
5.2.70.0050.0359.20
5.2.60.0060.0339.14
5.2.50.0050.0359.11
5.2.40.0030.0389.09
5.2.30.0070.0319.07
5.2.20.0040.0329.07
5.2.10.0070.0289.00
5.2.00.0050.0338.86
5.1.60.0040.0278.14
5.1.50.0050.0338.14
5.1.40.0040.0308.12
5.1.30.0070.0278.48
5.1.20.0050.0298.50
5.1.10.0070.0258.22
5.1.00.0040.0288.22
5.0.50.0060.0206.72
5.0.40.0050.0206.57
5.0.30.0010.0366.38
5.0.20.0070.0186.36
5.0.10.0020.0326.33
5.0.00.0020.0456.33
4.4.90.0120.0254.78
4.4.80.0060.0254.76
4.4.70.0040.0254.76
4.4.60.0060.0144.75
4.4.50.0020.0234.77
4.4.40.0020.0344.71
4.4.30.0040.0204.76
4.4.20.0030.0204.84
4.4.10.0030.0214.85
4.4.00.0040.0304.76
4.3.110.0020.0264.67
4.3.100.0050.0224.66
4.3.90.0050.0214.63
4.3.80.0040.0314.61
4.3.70.0040.0204.63
4.3.60.0120.0194.63
4.3.50.0020.0254.63
4.3.40.0090.0334.56
4.3.30.0070.0163.37
4.3.20.0140.0293.34
4.3.10.0050.0213.30
4.3.00.0030.0207.15

preferences:
150.68 ms | 1398 KiB | 7 Q