3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Template Name: Q&A */ get_header(); ?> <?php require_once('db_connect.php'); $userIDmarker = $_SESSION['userID']; ?> <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.validationEngine-en.js"></script> <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.validationEngine.js"></script> <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/validationEngine.jquery.css"> <script type="text/javascript"> function validateForm() { var x=document.forms["form1"]["Category"].value; if (x==null || x=="#") { alert("You must select a Category."); return false; } } jQuery(document).ready(function(){ jQuery("#form1").validationEngine('attach', {promptPosition : "topRight"}); jQuery(".deleteQuestion").click(function(){ var x = confirm("Are you sure want to delete this question?"); if(x){ var question_id = jQuery(this).attr('rel'); jQuery.ajax({ url:"<?php bloginfo("stylesheet_directory");?>/ajax.php?action=deleteQuestion", data:{question_id:question_id}, type:"POST", success:function(response){ if(response>0) jQuery("#box_"+question_id).remove(); } }); } }); jQuery(".deleteAns").click(function(){ var x = confirm("Are you sure want to delete this answer?"); if(x){ var answer_id = jQuery(this).attr('rel'); jQuery.ajax({ url:"<?php bloginfo("stylesheet_directory");?>/ajax.php?action=deleteAnswer", data:{answer_id:answer_id}, type:"POST", success:function(response){ if(response>0) jQuery("#answer_"+answer_id).remove(); } }); } }); $(".summary").keyup(function() { var len = jQuery(this).val().length; var max = 300; var left = 0; if (len <= max) { left = max - len; jQuery(this).siblings('.character_count').html("You have characters <span>" + left + "</span> left"); } }); $("#question_div").keyup(function() { var len = jQuery(this).val().length; var max = 140; var left = 0; if (len <= max) { left = max - len; jQuery('#character_count_question').html("You have characters <span>" + left + "</span> left"); } }); //document.write('<style type="text/css">input.styled { display: block; }</style>'); }); </script> <style> /* .character_count { margin-top: 17px !important; padding: 2px; } */ .character_count > span { color: red; } .character_count { float: right; margin-top: 4px; } #character_count_question { margin-right: 149px; margin-top: -11px; } </style> <?php if (isset($_POST['add'])) { if(!empty($_POST['hsecond_category'])) $level = $_POST['hsecond_category']; else $level = $_POST['Category']; $question = $_POST['singleQuestionContent']; $sqlCategory = "SELECT name from projectcategory WHERE catid = '$level'"; $resultCat = mysql_query($sqlCategory); $row = mysql_fetch_row($resultCat); $catName = $row[0]; $sql="INSERT INTO questions (Question, AuthorUserID, Category ) VALUES ('$question', '$userIDmarker','$catName');"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } else{ ?> <script> jQuery(document).ready(function(){ $('.darken').show(); show_permisson_project(); }); </script> <?php } } /* if (isset($_POST['upcomment']) && $_POST['Answer'] != "") { if ($_POST['currentcomment'] == "") { $updatedcomment = $_POST['Answer']. "^"; } else { $updatedcomment = $_POST['currentcomment'] . "^" . $_POST['Answer']; } $sql="UPDATE questions SET Answers='$updatedcomment' WHERE id = '$_POST[qid]'"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "<div class='updated'><p><strong>Updated!</strong> - Your comment has been added</p></div>"; } */ if(isset($_POST['submitAnswer'])){ $question_id = $_POST['qid']; $answer = $_POST['Answer']; $user_id = $_SESSION['userID']; $date = date('Y-m-d H:i:s',time()); $sql2 = "SELECT Question,AuthorUserID FROM questions WHERE id=$question_id"; $result2 = mysql_query($sql2); $data2 = mysql_fetch_assoc($result2); $question_title = $data2["Question"]; $sql = "SELECT EmailAddress FROM user WHERE UserID=".$data2['AuthorUserID']; $result = mysql_query($sql); $data = mysql_fetch_assoc($result); $authorEmail = $data["EmailAddress"]; $query = "INSERT INTO `qa_answers` " . "(`question_id`, `user_id`, `answer`, `date`, `status`) " . "VALUES ('$question_id', '$user_id', '$answer', '$date', '1');"; mysql_query($query); // multiple recipients $to = $authorEmail; //$to = "gilbert@123789.org"; // subject $subject = 'New answers posted'; $message = '<p>Dear User,<p><p>New comment posted on the <b><i>"'.$question_title.'"</i></b></p>'; $message .= '<p>Please click the link below to review.<br/> <a href="'.get_bloginfo("url").'/qa#box_'.$question_id.'">Click here</a>'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Hugyourhouse <amer@hugyourhouse.co.uk>' . "\r\n"; mail($to, $subject, $message, $headers); echo "<div class='updated'><p><strong>Updated!</strong> - Your comment has been added</p></div>"; } ?> <div id="inner_content"> <div class="page_content"> <h2 class="title"><?php the_title(); ?></h2> <?php if(!isset($_SESSION['username'])) { ?> <h5 style="float: right;margin: -57px 0 0 0;"><a class='footer_login' href='#login_wrap' >Login</a> today to ask your question</h5> <?php }?> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; ?> <?php if(isset($_SESSION['username'])) { ?> <div class="questionaskBox"> <form id="form1" name="form1" method="post" action="" onsubmit="return validateForm();"> <h5>Ask your question today by entering it in the box below</h5> <p><strong>Step 1:</strong> Choose your Category</p> <p style="float: left;width: 621px;"> <select name="Category" id="qmain_category" class="art-select validate[required]" style=" " > <option value="">Select primary category</option> <option value="2">Build</option> <option value="3">Decor</option> <option value="4">Indoor</option> <option value="5">Outdoor</option> <option value="6">Go Green</option> </select> </p> <p style="float: left;width: 621px;"> <select name="hsecond_category" class="art-select validate[required]" id="qsecond_category"> <option value="">Select sub category</option> </select> </p> <p><strong>Step 2:</strong> Ask your Question</p> <p> <textarea name="singleQuestionContent" class="validate[required]" cols="60" rows="5" id="question_div" maxlength="140"></textarea> <div class="character_count" id="character_count_question">You have characters <span>140</span> left</div></p> <input name="add" type="hidden" value="add" /> <input name="Ask your Question" type="submit" value="Submit Question" class="buttonStyleAdd" style="float: left; margin-top: -32px;" id="qsubmit"/> </form> </div> <?php } ?> <?php if (isset($_GET['cat'])) {$questioninfo = mysql_query("SELECT * FROM questions WHERE Category = '$_GET[cat]'");} else {$questioninfo = mysql_query("SELECT * FROM questions order by id desc");} while( $row = mysql_fetch_array( $questioninfo ) ){ ?> <div class="questionBox" id="box_<?php echo $row['id'];?>"> <a name="box_<?php echo $row['id'];?>"></a> <script type="text/javascript"> $('#seeanswers<?php echo $row['id']; ?>').click(function(){ $('#hiddenComments<?php echo $row['id']; ?>').toggle(); }); $('#giveanswer<?php echo $row['id']; ?>').click(function(){ $('#giveanswerBox<?php echo $row['id']; ?>').toggle(); }); </script> <h2><?php echo $row['Question']; ?></h2> <?php $sql2 = "SELECT AuthorUserID FROM questions WHERE id=".$row['id']; $result2 = mysql_query($sql2); $data2 = mysql_fetch_assoc($result2); $AuthorUserID = $data2["AuthorUserID"]; if($AuthorUserID==$userIDmarker || $_SESSION['type']==5){ ?> <a title="Delete this question" rel="<?php echo $row['id'];?>" class="delete deleteQuestion" href="javascript:void(0);" style="float: right; margin-top: -38px;">Delete</a> <?php }?> <p>Category: <?php echo $row['Category']; ?> | Posted By <?php $userInfo = mysql_query("SELECT * FROM user WHERE UserID = '$row[AuthorUserID]' LIMIT 1"); while( $userdata = mysql_fetch_array( $userInfo ) ){echo $userdata['FirstName']." ".$userdata['LastName'];}?> </a></p> <a id="seeanswers<?php echo $row['id']; ?>" onclick="showorhide('hiddenComments<?php echo $row['id']; ?>')">See Answers</a> or <a id="giveanswer<?php echo $row['id']; ?>" onclick="showorhide('giveanswerBox<?php echo $row['id']; ?>')">Answer this Question</a> <div class="hiddenComments" id="hiddenComments<?php echo $row['id']; ?>"> <?php /*$answer = explode('^', $row['Answers']); $answercounter = 0; while ( $answercounter < 10) { if ($answer[$answercounter]) { echo "<li>".$answer[$answercounter]."</li>"; } if ($answer[$answercounter]== "") {$answercounter = 15;} else { $answercounter++;} } */?> <?php $ansQuery = "SELECT * FROM qa_answers WHERE question_id= ".$row['id']; $resultAns = mysql_query($ansQuery); while($ans = mysql_fetch_assoc( $resultAns )){ $sqlUser = "SELECT FirstName,UserID FROM user WHERE UserID=".$ans['user_id']; $resultUser = mysql_query($sqlUser); $dataUser = mysql_fetch_assoc($resultUser); $name = $dataUser["FirstName"]; $ID = $dataUser["UserID"]; echo "<li id='answer_".$ans['ID']."'>".$ans["answer"]."<br/><small>".date('Y-m-d',strtotime($ans["date"]))."<small> By <a href='".get_bloginfo('url')."/user-profile/?userID=$ID'>$name</a>"; if($ans['user_id']==$userIDmarker || $AuthorUserID==$userIDmarker || $_SESSION['type']==5){ echo "<a class='delete deleteAns' href='javascript:void(0);' rel='".$ans['ID']."' style='float:right;'>Delete</a>"; } echo "</li>"; } ?> </div> <div class="giveanswerBox" id="giveanswerBox<?php echo $row['id']; ?>"> <?php if(isset($_SESSION['username'])) { ?> <form id="form2" name="form2" method="post" action=""> <div class="answerCon"> <textarea name="Answer" cols="60" rows="5" class="summary" style="text-align: left;width:600px !important; float:left !important; background-color:#fff !important; height:200px;" maxlength="300"></textarea> <div class="character_count">You have characters <span>300</span> left</div> <br /><br /><br /> </div> <!-- <input name="currentcomment" type="hidden" value="<?php echo $row['Answers']; ?>" /> <input name="qid" type="hidden" value="<?php echo $row['id']; ?>" /><input name="upcomment" type="hidden" value="yes" />--> <!-- <input name="Ask your Question" type="submit" value="Submit answer" class="buttonStyleAdd" style="float: left; margin-top: -32px;"/>--> <input name="qid" type="hidden" value="<?php echo $row['id']; ?>" /> <input name="author_id" type="hidden" value="<?php echo $row['AuthorUserID ']; ?>" /> <input name="submitAnswer" type="submit" value="Submit answer" class="buttonStyleAdd" style="float: left; margin-top: -32px;"/> </form> <? } else { echo "<br/><h5><a class='footer_login' href='#login_wrap'>Login</a> today to answer this question</h5>"; }?> </div> </div> <div class="clear"></div><!--clear--> <?php }?> </div><!--page_content--> <div id="sidebar"> <h3 class="widgettitle">Latest Questions & Answers by Category</h3> <ul id="category_list"> <li><a href="?cat=Build">Build</a></li> <li><a href="?cat=Decor">Decor</a></li> <li><a href="?cat=Indoor">Indoor</a></li> <li><a href="?cat=Outdoor">Outdoor</a></li> <li><a href="?cat=Go Green">Go Green</a></li> </ul> <div class="advert"> <p><small>SPONSORED ADVERT</small></p> <div class="advert_image"> <?php if (function_exists('dfrads')) { echo dfrads('1961087'); } ?> </div><!--advert_image--> </div><!--advert--> </div><!--sidebar--> <div class="clear"></div><!--clear--> </div><!--inner_content--> <div id="question_post" style="z-index:99999999;display:none;"> <div class="not_now"> <a href="#" onclick="hide_permisson_project(); return false;">Close</a> </div> <div class="sep"></div> <h2>Your question has been posted successfully.</h2> <div class="sep"></div> </div> <script> function hide_permisson_project() { $('#question_post').hide(); $('.darken').hide(); } function show_permisson_project() { $('.darken').show(); $('#question_post').show(); } </script> <?php get_footer(); ?>

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)
7.3.120.0100.01014.79
7.3.110.0090.00614.62
7.3.100.0000.01614.79
7.3.90.0100.00614.77
7.3.80.0040.00814.95
7.3.70.0030.01314.71
7.3.60.0070.00714.82
7.3.50.0120.00314.72
7.3.40.0000.00914.66
7.3.30.0060.00914.59
7.3.20.0090.00916.59
7.3.10.0000.01016.63
7.3.00.0000.01116.56
7.2.240.0070.01014.76
7.2.230.0070.00714.69
7.2.220.0120.00414.75
7.2.210.0030.01214.84
7.2.200.0100.00615.00
7.2.190.0070.01014.94
7.2.180.0060.00615.06
7.2.170.0030.01214.93
7.2.160.0030.01214.95
7.2.150.0060.01316.94
7.2.140.0060.00916.84
7.2.130.0080.00416.65
7.2.120.0070.00716.43
7.2.110.0030.01016.52
7.2.100.0060.00616.58
7.2.90.0120.00316.66
7.2.80.0090.00116.71
7.2.70.0060.00616.63
7.2.60.0060.00916.69
7.2.50.0100.00716.74
7.2.40.0140.00416.57
7.2.30.0070.00716.70
7.2.20.0030.01316.75
7.2.10.0060.01016.80
7.2.00.0050.00516.55
7.1.330.0060.01015.57
7.1.320.0090.00915.57
7.1.310.0110.00415.24
7.1.300.0090.00615.38
7.1.290.0000.00915.19
7.1.280.0030.01015.43
7.1.270.0140.00015.46
7.1.260.0080.00415.75
7.1.250.0030.00715.59
7.1.200.0030.00515.66
7.1.100.0040.01118.11
7.1.70.0000.00817.01
7.1.60.0070.01119.46
7.1.50.0030.01716.91
7.1.00.0000.08022.31
7.0.200.1000.00614.65
7.0.140.0030.07322.19
7.0.100.0030.08720.05
7.0.90.0100.08320.05
7.0.80.0100.07320.11
7.0.70.0100.04320.29
7.0.60.0070.07720.12
7.0.50.0100.08320.47
7.0.40.0070.06020.19
7.0.30.0030.08720.19
7.0.20.0070.05320.07
7.0.10.0070.04320.14
7.0.00.0170.07019.94
5.6.280.0030.07321.02
5.6.250.0030.07020.84
5.6.240.0170.04320.70
5.6.230.0070.08020.84
5.6.220.0000.05320.63
5.6.210.0030.06020.55
5.6.200.0130.08021.14
5.6.190.0100.08021.11
5.6.180.0170.07721.08
5.6.170.0070.09021.14
5.6.160.0070.08321.14
5.6.150.0070.08721.02
5.6.140.0030.05321.01
5.6.130.0030.07021.08
5.6.120.0100.08021.08
5.6.110.0030.08321.15
5.6.100.0070.05021.09
5.6.90.0070.09021.05
5.6.80.0070.08320.58
5.6.70.0100.07720.46
5.6.60.0000.08720.51
5.6.50.0030.04020.55
5.6.40.0100.07320.46
5.6.30.0100.04320.44
5.6.20.0070.08020.30
5.6.10.0100.07020.43
5.6.00.0030.07720.48
5.5.380.0030.08320.52
5.5.370.0200.07320.56
5.5.360.0130.07720.59
5.5.350.0070.08720.52
5.5.340.0100.08020.94
5.5.330.0100.07320.92
5.5.320.0100.06720.84
5.5.310.0000.09020.89
5.5.300.0100.08320.93
5.5.290.0200.06720.82
5.5.280.0070.10020.88
5.5.270.0100.06720.88
5.5.260.0000.08320.70
5.5.250.0130.07020.79
5.5.240.0030.09020.32
5.5.230.0000.08020.22
5.5.220.0070.04720.27
5.5.210.0070.04020.31
5.5.200.0170.04320.15
5.5.190.0170.06320.23
5.5.180.0070.09020.17
5.5.160.0100.04720.34
5.5.150.0170.04720.27
5.5.140.0130.07320.33
5.5.130.0070.07720.33
5.5.120.0070.07320.34
5.5.110.0030.08020.20
5.5.100.0030.06720.05
5.5.90.0030.08020.23
5.5.80.0100.06720.00
5.5.70.0030.04020.21
5.5.60.0100.04719.99
5.5.50.0100.03320.09
5.5.40.0030.04320.11
5.5.30.0030.04720.14
5.5.20.0130.04020.20
5.5.10.0030.04020.10
5.5.00.0100.03320.12
5.4.450.0100.07719.27
5.4.440.0000.06319.40
5.4.430.0130.07719.30
5.4.420.0000.08019.32
5.4.410.0100.07719.02
5.4.400.0070.08019.05
5.4.390.0100.05319.05
5.4.380.0170.07019.13
5.4.370.0030.04019.04
5.4.360.0000.06318.82
5.4.350.0070.07019.12
5.4.340.0000.08019.07
5.4.320.0070.07718.98
5.4.310.0100.07319.23
5.4.300.0100.07319.22
5.4.290.0100.07718.82
5.4.280.0070.07718.85
5.4.270.0070.08018.82
5.4.260.0130.05318.96
5.4.250.0070.07719.09
5.4.240.0000.04019.04
5.4.230.0170.03718.96
5.4.220.0070.03719.09
5.4.210.0030.07319.12
5.4.200.0000.04318.95
5.4.190.0070.04019.09
5.4.180.0000.04018.94
5.4.170.0030.03719.14
5.4.160.0070.03718.95
5.4.150.0030.03718.76
5.4.140.0000.04016.33
5.4.130.0030.03716.41
5.4.120.0000.07716.11
5.4.110.0000.04016.50
5.4.100.0070.07316.40
5.4.90.0070.05316.38
5.4.80.0000.03716.40
5.4.70.0070.05316.27
5.4.60.0070.04716.36
5.4.50.0030.03016.49
5.4.40.0130.03016.40
5.4.30.0030.03716.25
5.4.20.0000.03716.29
5.4.10.0000.04016.46
5.4.00.0070.03015.77

preferences:
38.56 ms | 401 KiB | 5 Q