3v4l.org

run code in 300+ PHP versions simultaneously
<?php ini_set('display_errors', 'On'); error_reporting(E_ALL); $time = microtime(); $time = explode(' ', $time); $time = $time[1] + $time[0]; $start = $time; session_start(); define("DB_HOST","mysql117.loopia.se"); define("DB_USER","normal@i103189"); define("DB_PASS","KungMicke87"); define("DB_NAME","indiehjaerta_com"); if (isset($_POST['send'])) { if (isset($_SESSION['username']) && isset($_SESSION['id'])) { // Connect to MySQLi $sqli = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME) or die(mysqli_errno()); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $fromid = $_SESSION['id']; $subject = mysqli_real_escape_string($sqli, $_POST['subject']); $text = mysqli_real_escape_string($sqli, $_POST['text']); $tousername = mysqli_real_escape_string($sqli, $_POST['username']); $postMessage = TRUE; $emptySubject = FALSE; $emptyText = FALSE; $toid = 0; $query = mysqli_query($sqli, "SELECT * FROM members WHERE username='".$tousername."'") or die("Error: ".mysqli_error($sqli)); $checkuser = mysqli_num_rows($query); if (empty($subject)) { $emptySubject = TRUE; $postMessage = FALSE; } elseif (empty($text)) { $emptyText = TRUE; $postMessage = FALSE; } elseif ($checkuser == 0) { $noValidUsername = TRUE; $postMessage = FALSE; } if ($postMessage == TRUE) { $row = mysqli_fetch_array($query); $toid = $row[id]; $timestamp = date('Y-m-d H:i:s'); $query = mysqli_query($sqli,"INSERT INTO privatemessages (`fromid`, `toid`, `subject`, `text`, `timestamp`) VALUES ('$fromid', '$toid', '$subject', '$text', '$timestamp')") or die("Error: ".mysqli_error($sqli)); header("location:messages.php?action=sent"); } else { $error = "There was an error posting the message."; } } } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <title>indiehjaerta.com - Messages</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="profile.php">Profile<a/> - <a href="messages.php">Messages<a/> - <a href="logout.php">Logout<a/> <br /> <hr /> <br /> <?php if (isset($_SESSION['username']) && isset($_SESSION['id'])) { if (isset($_GET['action']) && ($_GET['action'] == 'send')) { ?> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td> <strong>Message</strong> </td> </tr> <tr> <form method="post" action=""> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong>Send Message</strong></td> </tr> <tr> <td colspan="3"><?php if(isset($error)) { echo $error; } ?></td> </tr> <tr> <td width="78"><strong>To</strong></td> <td width="6">:</td> <td width="294"><input name="username" type="text" id="username"></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>Text</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="send" value="Send"></td> </tr> </table> </td> </form> </tr> </table> <?php } if (isset($_GET['action']) && ($_GET['action'] == 'read') && isset($_GET['id'])) { if ($_SESSION['id'] != $_GET['id'])) { header("location:messages.php?error=1"); } } else { if (isset($_GET['action']) && ($_GET['action'] == 'sent')) { ?> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3">Message sent!</td> </tr> </table> <br /> <?php } // 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(); } $id = $_SESSION['id']; $query = mysqli_query($sqli, "SELECT * FROM privatemessages WHERE toid='$id' ORDER BY timestamp DESC") or die("Error: ".mysqli_error($sqli)); $nummessages = mysqli_num_rows($query); ?> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td> <strong>Messages</strong> </td> </tr> <tr> <td> <?php if ($nummessages == 0) { ?> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3">Message box empty :(</td> </tr> </table> <?php } else { if (isset($_GET['error'])) { $error = "Stop Making Up Your Own Errors :("; if ($_GET['error'] == '1') { $error = "ERROR: You can only view your own messages"; } ?> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><?php echo $error; ?></td> </tr> </table> <?php } ?> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <th><strong>Read:</strong></th> <th><strong>Subject:</strong></th> <th><strong>From:</strong></th> <th><strong>Time:</strong></th> </tr> <? while ($row = mysqli_fetch_array($query)) { ?> <tr> <td> <?php if ($row['read'] == true) { echo "Yes"; } else { echo "No"; } ?> </td> <td><?php echo $row['subject'] ?></td> <td> <?php $uid = $row['fromid']; if ($uid == 0) { echo "SYSTEM"; } else { $userquery = mysqli_query($sqli, "SELECT * FROM members WHERE id='$uid'") or die("Error: ".mysqli_error($sqli)); $userexists = mysqli_num_rows($query); if ($userexists == 0) { echo "<deleted user>"; } else { $userrow = mysqli_fetch_array($userquery); echo $userrow['username']; } } ?> </td> <td><?php echo $row['timestamp'] ?></td> </tr> <?php } ?> </table> <?php } ?> </td> </tr> </table> <hr /> <a href="?action=send">Send Message</a> <?php } } else { ?> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td> <strong>Messages</strong> </td> </tr> <tr> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3">Can't fetch your messages since you're not logged in!</td> </tr> </table> </td> </tr> </table> <?php } ?> <hr /> <?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.0600.06018.85
5.4.280.0470.04018.96
5.4.270.0430.03719.24
5.4.260.0470.04018.87
5.4.250.0500.05718.87
5.4.240.0500.04718.86
5.4.230.0400.03318.98
5.4.220.0430.04318.97
5.4.210.0400.03319.21
5.4.200.0400.04318.86
5.4.190.0330.04018.99
5.4.180.0500.06319.23
5.4.170.0400.03719.30
5.4.160.0470.06319.22
5.4.150.0400.04018.99
5.4.140.0430.04016.39
5.4.130.0730.05016.35
5.4.120.0770.04016.68
5.4.110.0530.03316.60
5.4.100.0500.05016.54
5.4.90.0400.04016.60
5.4.80.0430.04016.28
5.4.70.0530.02716.54
5.4.60.0630.03716.43
5.4.50.0570.06016.29
5.4.40.0430.03716.48
5.4.30.0370.04016.43
5.4.20.0400.03716.43
5.4.10.0600.05716.48
5.4.00.0400.03715.83
5.3.280.0370.03714.57
5.3.270.0370.04014.68
5.3.260.0430.03314.47
5.3.250.0470.03714.47
5.3.240.0800.04314.58
5.3.230.0470.05014.45
5.3.220.0500.03714.46
5.3.210.0530.06314.53
5.3.200.0500.07014.47
5.3.190.0400.04014.47
5.3.180.0430.04714.57
5.3.170.0470.04314.43
5.3.160.0600.05714.45
5.3.150.0500.06714.43
5.3.140.0500.04314.47
5.3.130.0430.04014.43
5.3.120.0530.05314.52
5.3.110.0430.07314.51
5.3.100.0470.06714.00
5.3.90.0500.06314.00
5.3.80.0500.04713.95
5.3.70.0430.04713.99
5.3.60.0530.03313.88
5.3.50.0470.04013.93
5.3.40.0470.03713.75
5.3.30.0330.04013.98
5.3.20.0430.06313.68
5.3.10.0470.04013.57
5.3.00.0470.04013.53

preferences:
136.44 ms | 1394 KiB | 7 Q