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(); function tokenTruncate($string, $your_desired_width) { $parts = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE); $parts_count = count($parts); $length = 0; $last_part = 0; for (; $last_part < $parts_count; ++$last_part) { $length += strlen($parts[$last_part]); if ($length > $your_desired_width) { break; } } return implode(array_slice($parts, 0, $last_part)); } include 'connect.php'; $noBlogPostsFound = FALSE; // 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(); } if (!isset($_GET['page']) || !is_numeric($_GET['page']) || ($_GET['page'] < 0)) { $page = 0; } else { $page = (int)$_GET['page']; } $limit = 3; $start = $page * $limit; $query = mysqli_query($sqli, "SELECT * FROM blog ORDER BY timestamp DESC LIMIT $start, $limit") or die("Error: ".mysqli_error($sqli)); $checknumblogs = mysqli_num_rows($query); // Check if any blog posts exists if($checknumblogs == 0) { $noBlogPostsFound = TRUE; } else { $blogposts = array(); while ($row = mysqli_fetch_array($query)) { $userid = $row['userid']; $userquery = mysqli_query($sqli, "SELECT * FROM members WHERE id='$userid'") or die("Error: ".mysqli_error($sqli)); $userexists = mysqli_num_rows($userquery); if ($userexists == 0) { $username = "<deleted user>"; } else { $userrow = mysqli_fetch_assoc($userquery); $username = $userrow['username']; } $blogposts[] = array( "id" => $row['id'], "headline" => $row['headline'], "story" => $row['story'], "timestamp" => $row['timestamp'], "userid" => $row['userid'], "username" => $username ); } } $totalquery = mysqli_query($sqli, "SELECT * FROM blog") or die("Error: ".mysqli_error($sqli)); $totalblogposts = mysqli_num_rows($totalquery); //TOPINFOTEXT $textquery = mysqli_query($sqli, "SELECT * FROM toptext ORDER BY id") or die("Error: ".mysqli_error($sqli)); $textresult = mysqli_fetch_assoc($textquery); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <title>indiehjaerta.com ♥ Blog</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <!-- Font's --> <link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,300,400' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=Roboto:300,300italic' rel='stylesheet' type='text/css'> <link href="stylesheet/style.css" rel="stylesheet" type="text/css" /> <link href="stylesheet/blog.css" rel="stylesheet" type="text/css" /> </head> <body> <script type="text/javascript"> $(function() { $('#TopBarLogin').click(function() { $('#LoginPopUp').show(); return false; }); }); </script> <script type="text/javascript"> $(document).mouseup(function (e) { var container = $("#LoginPopUp"); if (!container.is(e.target) && container.has(e.target).length === 0) { container.hide(); } }); </script> <script type="text/javascript"> $(function() { if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) { var intervalId = 0; $(window).load(function() { intervalId = setInterval(function () { // << somehow this does the trick! if ($('input:-webkit-autofill').length > 0) { clearInterval(intervalId); $('input:-webkit-autofill').each(function () { var text = $(this).val(); var name = $(this).attr('name'); $(this).after(this.outerHTML).remove(); $('input[name=' + name + ']').val(text); }); } }, 1); }); } }); </script> <div id="TopBarImageContainer"> <div id="TopBarImage"></div> </div> <div id="MainContent"> <!-- NOT LOGGED IN HERE --> <a href="#"> <span class="DivLink"> <div id="TopBarLogin"> <span class="TopBarText">LOGIN <div id="TopBarTriangleDown"></div> </span> </div> </span> </a> <a href="register.php"> <span class="DivLink"> <div id="TopBarCreateAccount"> <span class="TopBarText">CREATE AN ACCOUNT</span> </div> </span> </a> <div id="TopBarUserMenu"> <div id="TopBarUserMenuProfile"> <a href="profile.php"> <span class="TopBarText"> <div id="TopBarUserMenuProfileImage"></div> <span class="DivLink"> PROFILE </span> </span> </a> </div> <div id="TopBarUserMenuMessages"> <a href="messages.php"> <span class="TopBarText"> <div id="TopBarUserMenuMessagesImage"></div> <span class="DivLink"> MESSAGES </span> </span> </a> </div> <div id="TopBarUserMenuSupport"> <a href="support.php"> <span class="TopBarText"> <div id="TopBarUserMenuSupportImage"></div> <span class="DivLink"> SUPPORT </span> </span> </a> </div> </div> <div id="LoginPopUp"> <form method="post" action=""> <input name="username" type="text" id="username" placeholder="Username" style="display: none" /> <input name="password" type="password" id="password" placeholder="Password" style="display: none" /> <input class="LoginInput" name="username" type="text" id="username" placeholder="Username" /><br /> <input class="LoginInput" name="password" type="password" id="password" placeholder="Password" /><br /> <input class="LoginButton" type="submit" name="login" value=""> </form> </div> <div id="LogoMenu"> <div id="SocialTopLinks"> <div id="SocialTopTwitterLink"> <a href="http://www.twitter.com/indiehjaerta"> <span class="DivLink"></span> </a> </div> <div id="SocialTopFacebookLink"> <a href="http://www.facebook.com/indiehjaerta"> <span class="DivLink"></span> </a> </div> <div id="SocialTopInstagramLink"> <a href="http://www.instagram.com/indiehjaerta"> <span class="DivLink"></span> </a> </div> <div id="SocialTopTwitchLink"> <a href="http://www.twitch.tv/indiehjaerta"> <span class="DivLink"></span> </a> </div> </div> <div id="TopLogo"> <a href="#"><span class="DivLink"></span></a> </div> <div id="MenuLinkSeparator"></div> <div id="MenuLinks"> <a href="" class="Menu">HOME</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="news.php" class="Menu">NEWS</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="blog.php" class="Menu">BLOG</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="events.php" class="Menu">EVENTS</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="forums.php" class="Menu">FORUMS</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="" class="Menu">CONTACT</a> </div> </div> <div id="Container"> <div id="InfoHeader"></div> <div id="Content"> <div id="BlogContent"> <?php //WRITE OUT IF NO BLOG POSTS FOUND! $counter = 0; foreach ($blogposts as $post) { $counter++; ?> <a href="?id=<?php echo $post['id'] ?>" class="BlogPostHeadlineList"><?php echo strtoupper($post['headline']) ?></a><br /> <span class="BlogPostInfoList">posted by <a href="profile.php?id=<?php echo $post['userid'] ?>"><?php echo $post['username'] ?></a> at <?php echo $post['timestamp'] ?></span><br /> <div id="BlogContentText"> <span class="BlogPostTextList"><?php echo tokenTruncate($post['story'], 550); if (strlen($post['story']) > 550) { echo '...'; } ?></span><br /> </div> <div class="BlogButtonContainer"> <?php if (strlen($post['story']) > 550) { ?> <a href="<?php echo $_SERVER['PHP_SELF'].'?id='.$post['id'] ?>"><img src="images/buttonreadmore.png" class="ButtonReadMore" /></a> <?php } ?> <a href="<?php echo $_SERVER['PHP_SELF'].'?id='.$post['id']. '#comments' ?>"><img src="images/buttoncomments.png" class="ButtonComment" /></a> </div> <?php if ($counter < $limit) { //RENAME BELOW ?> <img src="images/separator-horizontal-long.png" id="BlogSeparatorHorizontal" /><br /> <?php } } ?> </div> <div id="BlogLinks"> <span class="BlogNavigationLink"> <?php if ($page > 0) { $prev = $start - $limit; echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$prev.'" class="BlogNavigationLink">« Newer posts</a> '; } else { echo '« Newer posts '; } $maxpages = floor($totalblogposts/$limit); echo '<span class="BlogNavigationLink">'; for ($i = 0; $i <= $maxpages; $i++) { echo '<a href=".$_SERVER['PHP_SELF'] .'?page=' .$i. '" class="BlogNavigationLink">' .($i+1). '</a> '; } echo '</span>'; if ($page < $maxpages) { $nextpage = $page+1; echo ' <a href="'.$_SERVER['PHP_SELF'].'?page='.$nextpage.'" class="BlogNavigationLink">Older Posts »</a>'; } else { echo ' Older Posts »'; } ?> </span> </div> <div id="NewsLetterBanner"> </div> </div> <div id="Bot"> <div id="BotLogo"> <a href="#"><span class="DivLink"></span></a> </div> </div> </div> </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.300.0060.03812.59
5.4.290.0070.04212.58
5.4.280.0080.04012.48
5.4.270.0240.07212.48
5.4.260.0270.13912.48
5.4.250.0060.05412.48
5.4.240.0160.04412.48
5.4.230.0060.05312.47
5.4.220.0130.09212.47
5.4.210.0100.04312.47
5.4.200.0100.04512.47
5.4.190.0050.03712.47
5.4.180.0080.03612.46
5.4.170.0070.03412.47
5.4.160.0060.03512.47
5.4.150.0090.03312.46
5.4.140.0050.03712.16
5.4.130.0060.03612.13
5.4.120.0080.03212.11
5.4.110.0050.03612.09
5.4.100.0090.03112.10
5.4.90.0060.04112.09
5.4.80.0150.03912.10
5.4.70.0070.03312.10
5.4.60.0060.03412.09
5.4.50.0040.03812.09
5.4.40.0060.03912.08
5.4.30.0060.04112.08
5.4.20.0010.04012.07
5.4.10.0030.03912.08
5.4.00.0100.04411.57
5.3.280.0090.05812.73
5.3.270.0060.03912.74
5.3.260.0090.03512.73
5.3.250.0060.03612.73
5.3.240.0060.03612.73
5.3.230.0060.04012.72
5.3.220.0040.03812.69
5.3.210.0090.05712.70
5.3.200.0110.03212.69
5.3.190.0080.03412.69
5.3.180.0050.03912.69
5.3.170.0090.04512.69
5.3.160.0100.03812.69
5.3.150.0050.03712.69
5.3.140.0070.04112.68
5.3.130.0060.04412.67
5.3.120.0060.04512.67
5.3.110.0080.04812.67
5.3.100.0010.04012.16
5.3.90.0090.04112.14
5.3.80.0060.03612.13
5.3.70.0040.03812.14
5.3.60.0060.04212.12
5.3.50.0050.03612.07
5.3.40.0060.03612.07
5.3.30.0080.03212.02
5.3.20.0040.03811.81
5.3.10.0080.04611.77
5.3.00.0080.03411.76
5.2.170.0060.0419.28
5.2.160.0080.0309.28
5.2.150.0040.0309.28
5.2.140.0080.0299.27
5.2.130.0040.0299.23
5.2.120.0030.0319.23
5.2.110.0050.0319.24
5.2.100.0050.0329.23
5.2.90.0060.0399.24
5.2.80.0070.0429.23
5.2.70.0050.0319.23
5.2.60.0080.0399.18
5.2.50.0030.0329.15
5.2.40.0050.0409.13
5.2.30.0060.0299.11
5.2.20.0060.0299.11
5.2.10.0080.0269.01
5.2.00.0060.0398.87
5.1.60.0050.0248.17
5.1.50.0050.0268.17
5.1.40.0090.0298.15
5.1.30.0040.0318.50
5.1.20.0070.0348.53
5.1.10.0060.0248.25
5.1.00.0060.0308.25
5.0.50.0050.0216.72
5.0.40.0010.0226.58
5.0.30.0020.0326.40
5.0.20.0020.0206.37
5.0.10.0040.0216.34
5.0.00.0010.0326.34
4.4.90.0010.0184.78
4.4.80.0020.0174.75
4.4.70.0020.0174.75
4.4.60.0030.0154.76
4.4.50.0050.0154.77
4.4.40.0020.0264.71
4.4.30.0030.0154.76
4.4.20.0030.0164.84
4.4.10.0060.0124.85
4.4.00.0030.0254.76
4.3.110.0040.0154.67
4.3.100.0030.0164.67
4.3.90.0030.0164.63
4.3.80.0030.0254.61
4.3.70.0040.0234.63
4.3.60.0030.0164.63
4.3.50.0100.0304.63
4.3.40.0050.0334.57
4.3.30.0140.0303.38
4.3.20.0040.0203.36
4.3.10.0040.0193.31
4.3.00.0170.0137.25

preferences:
142.09 ms | 1394 KiB | 7 Q