3v4l.org

run code in 300+ PHP versions simultaneously
<? require './shared_lib/core.php'; $admin = ($_SERVER['REMOTE_ADDR'] !== '82.19.119.31') ?false:true; //stderr('Error','Access Denied'); init(); $actions = array('/index.php?action=new'=>'New'); if (isset($_REQUEST['id']) && is_valid_id($_REQUEST['id'])) $actions = array_merge($actions, array('/index.php?action=edit&amp;id='.$_REQUEST['id']=>'Edit','/index.php?action=delete&amp;id='.$_REQUEST['id']=>'Delete')); $action = isset($_REQUEST['action']) && in_array(ucfirst($_REQUEST['action']),$actions) ? ucfirst($_REQUEST['action']) : ''; $opts = array('js'=>array('jquery.markitup','bbcode')); $form = array('news','id,userid,added,body,title', 'WHERE class >= ', // for permissions for edit/new ... will be done via permissions system so in php array('id'=>'primary|int', 'userid'=>'int|validid', 'added'=>'now', 'title'=>'trim|htmlspecialchars|sqlesc', 'body'=>'bbcode'), array('',array( 8=>array('title','text'))) ); // convert datetime to unixtimestamp /* comments_torrents, requests etc // parent just id of parent, in php put as subarray when doing query (sort by id desc) and then in displaying use media object <li> for proper nesting display... done ;) $form = array('comments_*','id,userid,pid,added,body,editedby,editdat,parent', array('id'=>'primary','userid'=>'int|validid','pid'=>'int|validid','added'=>'new_now','body'=>'bbcode','editedby'=>'curuser','editdat'=>'now', 'parent'=>'id|validid'), // look array .... ); */ // manage_form($form) // if we have bbcode parsing if ($action) { if ($_SERVER['REQUEST_METHOD'] === 'POST') require './shared_lib/bb/bbparse.php'; if ($_SERVER['REQUEST_METHOD'] === 'GET' || $action === 'Edit') require './shared_lib/bb/bbinput.php'; } $exclude = array('id','userid'); $arr = explode(',',$form[1]); $table = $form[0]; if ($action === 'New') { if ($_SERVER['REQUEST_METHOD'] === 'POST' && $admin) { foreach ($arr as $r) { if (!in_array($r,$exclude)) { $tmp = isset($_REQUEST[$r]) ? $_REQUEST[$r] : -1; /* if (isset($checks[$r])) { $chk = explode('|', $checks[$r]); $tmp = validate(array($r,$tmp), $chk); if (is_array($tmp) && count($tmp['errors'])) $errors[] = $tmp['errors']; else $q[$r] = $tmp['value']; } else*/ switch ($r) { // temp case 'added': $tmp = 'NOW()';$q[$r] = $tmp; break; case 'body': $tmp = bb2html($tmp); default: $q[$r] = sqlesc($tmp); } } } $f = array_keys($q); $r = do_mysql_query('INSERT INTO '.$table.' ('.implode(', ',$f).') VALUES ('.implode(', ',$q).')') or sqlerr(__FILE__,__LINE__,$actions); if (mysql_affected_rows()) stderr('Success','Well done'); else stderr('Error','Failed'); } stdhead('New Blog Post',$actions, $opts); start_container('new_blog'); // form functions // 'horizontal', 'post','action' // title=>text, bbcode, button=>submit $content = print_form('new'); grid(array(array('',array(12=>$content)))); end_container(); stdfoot(); } else if ($action === 'Edit' && $admin) { $id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 0; if (!$id) stderr('Error','Invalid ID'); $res = do_mysql_query('SELECT '.$form[1].',UNIX_TIMESTAMP(added) uadded FROM '.$table.' WHERE id='.$id) or sqlerr(__FILE__,__LINE__, $actions); if (mysql_num_rows($res) == 0) stderr('Error','Not Found!'); $vars = mysql_fetch_array($res); if ($_SERVER['REQUEST_METHOD'] === 'POST') { $q = array(); foreach ($arr as $r) { if (!in_array($r,$exclude)) { $tmp = isset($_REQUEST[$r]) ? $_REQUEST[$r] : -1; /* if (isset($checks[$r])) { $chk = explode('|', $checks[$r]); $tmp = validate(array($r,$tmp), $chk); if (is_array($tmp) && count($tmp['errors'])) $errors[] = $tmp['errors']; else $q[$r] = $tmp['value']; } else*/ switch ($r) { // temp case 'added': break; /*$tmp = 'NOW()';$q[$r] = $tmp; break;*/ case 'body': if ($vars['body'] === $tmp) break; $tmp = bb2html($tmp,$table.$id); default: if ($vars[$r] === $tmp) break; $q[$r] = sqlesc($tmp); } } } if (sizeof($q) === 0) stderr('Error','No Changes found!'); $f = ''; foreach ($q as $r => $v) $f .= ($f?',':'').$r.'='.$v; $r = do_mysql_query('UPDATE '.$table.' SET '.$f.' WHERE id='.$id) or sqlerr(__FILE__,__LINE__,$actions); if (mysql_affected_rows()) stderr('Success','Well done'); else stderr('Error','Failed'); } $vars['body'] = html2bb($vars['body'],$table.$id); stdhead('Edit Blog Post',$actions, $opts); start_container('new_blog'); // form functions // 'horizontal', 'post','action' // title=>text, bbcode, button=>submit $content = print_form('edit',$vars); grid(array(array('',array(12=>$content)))); end_container(); stdfoot(); } else if ($action === 'Delete') { // have to add mkd5 key to prevent replay attacks etc if (isset($_REQUEST['id']) && is_valid_id($_REQUEST['id'])) { $r = do_mysql_query('SELECT '.$form[1].' FROM '.$table.' WHERE id='.$_REQUEST['id']) or sqlerr(__FILE__,__LINE__); if (!mysql_num_rows($r)) stderr('Error','Not Found!',$actions); else { $r = mysql_fetch_array($r); if (isset($_REQUEST['sure']) && $_REQUEST['sure'] == 1) { do_mysql_query('DELETE FROM '.$table.' WHERE id='.(int)$_REQUEST['id']) or sqlerr(__FILE__,__LINE__); stderr('Success',$table.' was deleted',$actions); } else stderr('Are you sure? ','Click <a href="?q='.$table.'&amp;action=delete&amp;sure=1&amp;id='.(int)$_REQUEST['id'].'">HERE</a> if you are certain you wnat to delete \'<strong>'.$r['title'].'</strong>\'',$actions); } } } $main = $side = ''; $res = do_mysql_query('SELECT '.$form[1].',UNIX_TIMESTAMP(added) uadded FROM '.$table.' ORDER BY added DESC') or sqlerr(__FILE__,__LINE__, $actions); if (mysql_num_rows($res) === 0) $main = alert('Error','No News','warning'); else while ($arr= mysql_fetch_array($res)) { $main .= '<div class="blog-post" id="bpp'.$arr['id'].'">'. h( make_links(array('#bpp'.$arr['id']=>array($arr['title'],array('id'=>'bl'.$arr['id'],'data-toggle'=>'collapse','data-target'=>'#bp'.$arr['id']))),' '), 2,array('class'=>'blog-post-title','id'=>'bt'.$arr['id']) ). '<div class="blog-post-meta">'.$arr['added'].' ('.get_elapsed_time($arr['uadded']).' ago} by '.$arr['userid']. '<span class="blog-controls">'. make_links(array('index.php?action=edit&amp;id='.$arr['id']=>array(icon('edit','',array('class'=>'control')),array('class'=>'url','title'=>'Edit Post')),'index.php?action=delete&amp;id='.$arr['id']=>array(icon('remove','',array('class'=>'control')),array('title'=>'Remove Post','class'=>'url'))),'&nbsp;'). '</span></div><div id="bp'.$arr['id'].'" class="collapse in">'. $arr['body']. '</div></div>'; } $page = array(array('',array(8=>$main),array(4=>$side))); stdhead('Welcome', $actions); start_container('blog'); grid($page); end_container(); /* start_container('table'); drawtable(do_mysql_query('SELECT * FROM news')); end_container(); */ stdfoot(); function print_form($action, $vars = array()) { $form_id = 'body'; $ex = ($action === 'edit' && ($id = $vars['id'])) ? '<input type="hidden" name="id" value="'.$id.'">' : ''; $content = '<form role="form" class="form-horizontal" action="?" method="post">'.$ex.'<input type="hidden" name="action" value="'.$action.'"> <div class="form-group"> <label for="title" class="col-sm-2 control-label">Title</label> <div class="col-sm-8"> <input type="text" class="form-control" id="title" name="title" placeholder="Blog Title" value="'.(isset($vars['title'])?$vars['title']:'').'"> </div> </div> <div class="form-group"> <label for="bbcode-body" class="col-sm-2 control-label">Body</label> <div class="col-sm-10"> '.textbbcode('',$form_id,isset($vars['body'])?$vars['body']:''). '</div></div> <span id="emoticons" class="col-sm-offset-2 pull-left">'.emoticon_rand(20,1).'</span>&nbsp; <button id="random_emot" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-refresh"></span></button> <button id="more_bb" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-plus"></span></button> <div id="controls-'.$form_id.'" class="pull-right">&nbsp;'.button(($action === 'edit' ? 'Save':'Post'),'i','primary').'</div></form>'; return $content; } // textbbcode will handle emoticon printing.. always print control div but button are from form! ?>

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.0110.01116.25
8.3.50.0110.01022.87
8.3.40.0110.00318.71
8.3.30.0070.00718.92
8.3.20.0050.00320.38
8.3.10.0000.00823.53
8.3.00.0040.00419.13
8.2.180.0110.00416.38
8.2.170.0100.00622.96
8.2.160.0030.01020.43
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0030.00520.91
8.2.110.0030.00520.35
8.2.100.0100.00617.78
8.2.90.0090.00017.75
8.2.80.0030.00518.73
8.2.70.0050.00517.63
8.2.60.0030.00517.59
8.2.50.0040.00417.93
8.2.40.0030.00517.90
8.2.30.0020.00517.87
8.2.20.0040.00417.68
8.2.10.0030.00618.08
8.2.00.0020.00517.58
8.1.280.0170.00325.92
8.1.270.0090.00023.97
8.1.260.0040.00426.35
8.1.250.0090.00028.09
8.1.240.0060.00320.66
8.1.230.0110.00017.70
8.1.220.0030.00517.74
8.1.210.0040.00418.77
8.1.200.0030.00717.10
8.1.190.0000.00817.10
8.1.180.0030.00518.10
8.1.170.0040.00417.62
8.1.160.0000.00721.86
8.1.150.0040.00418.68
8.1.140.0040.00417.30
8.1.130.0030.00317.81
8.1.120.0000.00817.39
8.1.110.0000.00717.34
8.1.100.0030.00617.38
8.1.90.0050.00417.31
8.1.80.0050.00217.30
8.1.70.0030.00317.29
8.1.60.0070.00017.40
8.1.50.0000.00817.43
8.1.40.0000.00717.40
8.1.30.0030.00517.46
8.1.20.0040.00417.54
8.1.10.0000.00717.35
8.1.00.0000.00817.32
8.0.300.0000.00818.77
8.0.290.0080.00416.63
8.0.280.0040.00418.46
8.0.270.0000.00717.21
8.0.260.0080.00017.19
8.0.250.0070.00016.86
8.0.240.0060.00316.84
8.0.230.0030.00516.78
8.0.220.0030.00316.81
8.0.210.0030.00316.78
8.0.200.0060.00016.71
8.0.190.0030.00616.91
8.0.180.0060.00616.82
8.0.170.0000.00716.80
8.0.160.0000.00716.81
8.0.150.0040.00416.72
8.0.140.0030.00616.65
8.0.130.0060.00013.59
8.0.120.0040.00416.68
8.0.110.0040.00416.69
8.0.100.0030.00516.60
8.0.90.0000.00716.66
8.0.80.0030.01816.79
8.0.70.0040.00416.76
8.0.60.0040.00416.85
8.0.50.0070.00016.60
8.0.30.0120.00717.01
8.0.20.0090.00917.40
8.0.10.0040.00416.72
8.0.00.0100.00716.73
7.4.330.0000.00515.15
7.4.320.0030.00316.45
7.4.300.0000.00616.41
7.4.290.0040.00416.41
7.4.280.0060.00316.41
7.4.270.0000.00616.38
7.4.260.0090.00016.30
7.4.250.0070.00016.41
7.4.240.0050.00216.49
7.4.230.0030.00316.59
7.4.220.0030.01416.48
7.4.210.0030.01016.57
7.4.200.0030.00316.38
7.4.160.0030.01216.49
7.4.150.0050.01417.40
7.4.140.0130.00517.86
7.4.130.0100.01116.30
7.4.120.0120.00516.44
7.4.110.0130.00716.29
7.4.100.0070.01016.51
7.4.90.0140.00316.39
7.4.80.0040.01519.39
7.4.70.0070.01016.23
7.4.60.0100.00716.27
7.4.50.0040.00016.00
7.4.40.0030.01316.48
7.4.30.0070.01416.60
7.4.00.0030.01314.88
7.3.330.0050.00013.41
7.3.320.0030.00313.48
7.3.310.0030.00316.11
7.3.300.0070.00016.00
7.3.290.0110.00316.11
7.3.280.0100.00716.16
7.3.270.0110.00717.40
7.3.260.0110.00716.26
7.3.250.0050.01116.38
7.3.240.0150.00416.48
7.3.230.0040.01216.39
7.3.210.0120.00616.46
7.3.200.0100.01019.39
7.3.190.0140.01216.25
7.3.180.0040.01216.12
7.3.170.0080.00816.27
7.3.160.0100.00716.21
7.2.330.0170.00016.31
7.2.320.0130.00316.55
7.2.310.0160.00316.41
7.2.300.0060.01616.36
7.2.290.0070.01016.53
7.2.60.0090.00616.91
7.2.00.0070.00719.11
7.1.200.0070.00415.81
7.1.100.0000.01218.11
7.1.70.0040.00717.02
7.1.60.0070.01019.40
7.1.50.0260.01034.23
7.1.00.0000.08022.32
7.0.200.0280.00614.51
7.0.140.0200.06022.04
7.0.100.0130.06720.04
7.0.90.0100.04720.13
7.0.80.0100.08020.05
7.0.70.0200.06720.02
7.0.60.0030.06720.12
7.0.50.0030.08320.43
7.0.40.0130.05320.13
7.0.30.0070.08020.00
7.0.20.0100.07720.08
7.0.10.0100.07720.04
7.0.00.0070.07320.10
5.6.280.0100.06721.15
5.6.250.0000.09020.84
5.6.240.0100.08720.65
5.6.230.0030.04720.66
5.6.220.0030.08020.66
5.6.210.0000.08720.64
5.6.200.0200.07321.16
5.6.190.0100.07021.21
5.6.180.0070.08321.12
5.6.170.0030.06021.16
5.6.160.0070.08321.07
5.6.150.0070.08721.04
5.6.140.0130.08021.21
5.6.130.0030.05721.01
5.6.120.0100.07021.18
5.6.110.0070.08721.21
5.6.100.0100.03721.07
5.6.90.0100.04721.02
5.6.80.0130.05720.57
5.6.70.0230.08320.39
5.6.60.0100.07720.38
5.6.50.0070.06320.55
5.6.40.0130.07320.48
5.6.30.0000.07720.48
5.6.20.0100.08020.38
5.6.10.0070.04720.46
5.6.00.0100.07720.48
5.5.380.0070.08320.48
5.5.370.0130.03320.59
5.5.360.0100.07320.44
5.5.350.0030.07720.49
5.5.340.0030.09320.81
5.5.330.0100.08320.95
5.5.320.0100.08020.96
5.5.310.0130.04320.98
5.5.300.0130.07320.98
5.5.290.0170.04720.95
5.5.280.0030.09020.99
5.5.270.0200.06320.95
5.5.260.0170.05020.69
5.5.250.0100.06720.53
5.5.240.0170.06720.35
5.5.230.0030.08720.38
5.5.220.0030.05320.23
5.5.210.0230.05720.39
5.5.200.0130.07320.17
5.5.190.0030.07720.23
5.5.180.0230.07020.33
5.5.160.0200.06720.30
5.5.150.0270.04020.14
5.5.140.0100.07320.19
5.5.130.0030.08020.32
5.5.120.0130.06720.21
5.5.110.0100.07720.06
5.5.100.0130.07320.20
5.5.90.0200.07720.15
5.5.80.0070.07320.23
5.5.70.0100.06020.22
5.5.60.0030.08020.01
5.5.50.0030.04720.07
5.5.40.0100.07720.18
5.5.30.0130.07720.23
5.5.20.0100.06320.14
5.5.10.0100.04320.17
5.5.00.0200.07320.14
5.4.450.0070.05019.55
5.4.440.0170.05719.22
5.4.430.0030.05019.20
5.4.420.0030.04319.48
5.4.410.0100.08019.42
5.4.400.0030.08019.17
5.4.390.0030.07719.05
5.4.380.0170.06718.91
5.4.370.0130.07019.07
5.4.360.0070.07719.13
5.4.350.0200.06719.17
5.4.340.0100.07319.22
5.4.320.0100.04018.93
5.4.310.0070.07319.16
5.4.300.0100.05318.86
5.4.290.0100.07319.07
5.4.280.0130.07719.05
5.4.270.0030.08019.05
5.4.260.0100.06719.13
5.4.250.0100.07318.90
5.4.240.0170.07019.18
5.4.230.0070.05018.90
5.4.220.0070.07719.16
5.4.210.0030.05019.04
5.4.200.0100.05018.91
5.4.190.0070.07319.11
5.4.180.0000.04319.13
5.4.170.0100.08018.97
5.4.160.0130.07019.15
5.4.150.0000.08718.89
5.4.140.0000.08016.55
5.4.130.0070.06716.50
5.4.120.0100.06716.52
5.4.110.0200.06316.50
5.4.100.0070.07716.48
5.4.90.0130.06716.34
5.4.80.0100.04716.31
5.4.70.0070.07316.38
5.4.60.0100.04716.43
5.4.50.0100.07016.54
5.4.40.0170.06316.54
5.4.30.0130.05016.46
5.4.20.0030.07016.41
5.4.10.0130.06716.50
5.4.00.0030.04315.93

preferences:
55.67 ms | 401 KiB | 5 Q