3v4l.org

run code in 300+ PHP versions simultaneously
<?PHP /* LookingGlass dgs-bootstraphtml.php */ define('dgs_void_tags', '<area><base><br><col><command><embed><hr><img><input><link><meta><param><source>'); define('dgs_CG_OPEN', '<div class="control-group">'); define('dgs_CG_CLOSE', '</div>'); define('dgs_HELP_OPEN', '<p class="help-block">'); define('dgs_HELP_CLOSE', '</p>'); $dgs_regNames = array(); function dgs_isVoidTag( $tagName ) { return (stripos(dgs_void_tags,'<'.$element.'>')!==false); } function dgs_nextRegNameID( $regName ) { global $dgs_regNames; if(isset($dgs_regNames[$regName])) { $dgs_regNames[$regName]++; } else { $dgs_regNames[$regName] = 0; } return $regName.$dgs_regNames[$regName]; } function dgs_attributes($OPTIONS) { $out = ''; foreach($OPTIONS as $parm => $val) { if(($parm[0]!='_')&&(!empty($val))) $out .= ' '.$parm.'="'.$val.'"'; } return $out; } function dgs_element($type, $text, $OPTIONS=array(), $print=true) { // create an element // $OPTIONS = array of option settings {including but not limited to:} // '_style' => {blank} | primary | success | info | warning | danger | inverse | link (string) // '_size' => large | {blank} | small | mini (string) // '_disabled' => true | false (boolean) // '_element' => a | button | input (string) // 'href' => {target URL} | # // 'type' => {blank} | button | input | submit // 'name' => {element name} // 'id' => {element id} // 'value' => {element value} $o = $OPTIONS; if(!isset($o['_element'])) return false; $element = strtolower($o['_element']); $class = (($type!='icon')?$type:''); $class .= ((!empty($o['_style']))?" $type-".$o['_style']:''); $class .= ((!empty($o['_size']))?" $type-".$o['_size']:''); $class .= ((!empty($o['_disabled']))&&($o['_disabled']==true))?' disabled':''); $class .= ((!empty($o['_inline']))&&($o['_inline']==true))?' inline':''); $class .= ((isset($o['class']))?' '.$o['class']:''); $class = trim($class); $o['class'] = $class; if($o['_disabled']==true)$o['disabled']='disabled'; $attr = dgs_attributes($o); $out = vsprintf('<%1$s %2$s>%3$s'.((!dgs_isVoidTag($element))?'</%1$s>':''), array( $element, $attr, $text, )); if(!empty($o['_help'])) $out.=dgs_HELP_OPEN.$o['_help'].dgs_HELP_CLOSE; if ($print==true) { echo $out; return true; } else { return $out; } } function dgs_button($text, $OPTIONS=array(), $print=true) { // create a button // $OPTIONS = array of option settings {including but not limited to:} // '_style' => {blank} | primary | info | success | warning | danger | inverse | link // '_size' => large | {blank} | small | mini $o = array( '_element' => 'button', 'type' => (empty($OPTIONS['type'])?'button':$OPTIONS['type']), ); return dgs_element('btn', $text, array_merge($OPTIONS, $o), $print); } function dgs_buttonA($text, $OPTIONS=array(), $print=true) { // create a button // $OPTIONS = array of option settings {including but not limited to:} // '_style' => {blank} | primary | info | success | warning | danger | inverse | link // '_size' => large | {blank} | small | mini $o = array( '_element' => 'a', 'href' => (empty($OPTIONS['href'])?'#':$OPTIONS['href']), ); return dgs_element('btn', $text, array_merge($OPTIONS, $o), $print); } function dgs_buttonI($text, $OPTIONS=array(), $print=true) { // create a button // $OPTIONS = array of option settings {including but not limited to:} // '_style' => {blank} | primary | info | success | warning | danger | inverse | link // '_size' => large | {blank} | small | mini $o = array( '_element' => 'input', 'type' => (empty($OPTIONS['type'])?'button':$OPTIONS['type']), 'value' => (empty($OPTIONS['value'])?((!empty($text))?$text:'Submit'):$OPTIONS['value']), ); return dgs_element('btn', '', array_merge($OPTIONS, $o), $print); } function dgs_checkbox($name, $label, $value="1", $checked=false, $OPTIONS=array(), $print=true) { // create a checkbox input // wrapped in CLASS GROUP unless _inline option is true. // $OPTIONS = array of option settings {including but not limited to:} // _inline = false | true (boolean) // _disabled = false | true (boolean) // _help = {help block text, shown after element} // id = {automatically assigned if left blank} if(empty($name)) return false; $o = array( 'checked' => (($checked)?'checked':''), 'value' => $value, 'id' => ((empty($OPTIONS['id']))?dgs_nextRegNameID($name):$OPTIONS['id']), '_element' => 'input', 'type' => 'checkbox', 'name' => $name, 'class' => '', '_help' => '', ); $class = "checkbox".((!empty($OPTIONS['class']))?' '.$OPTIONS['class']:'').(((!empty($OPTIONS['_inline']))&&($OPTIONS['_inline']==true))?' inline':''); $out = '<label class="'.$class.'">'.dgs_element('','', array_merge($OPTIONS, $o), false).'</label>'; if(!empty($OPTIONS['_help'])) $out.=dgs_HELP_OPEN.$OPTIONS['_help'].dgs_HELP_CLOSE; if ((!empty($OPTIONS['_inline']))&&($OPTIONS['_inline']!=true)) $out = dgs_CG_OPEN.$out.dgs_CG_CLOSE; if ($print) { echo $out; return true; } return $out; } function dgs_alert($text, $OPTIONS=array(), $print=true) { // create a dismissable alert box // $OPTIONS = array of option settings {including but not limited to:} // '_style' => {blank} | "error" | "success" | "info" $o = $OPTIONS; $o['_size'] = ((strlen($text) > 80)?'block':''); $o['_element'] = 'div'; $b = array( '_element' => 'button', 'type' => 'button', 'data-dismiss' => 'alert' ); $btn = dgs_element('close', '&times;', $b, false); return dgs_element('alert', $btn.$text, $o, $print ); } dgs_checkbox('mybox', "My Checkbox"); ?>

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.6.80.0070.06020.52
5.5.240.0200.04020.29
5.4.400.1270.06018.52
5.4.390.1130.05718.84
5.4.380.1270.07318.63
5.4.370.1470.07318.61
5.4.360.1370.04718.60
5.4.350.1170.06018.78
5.4.340.1270.05318.78
5.4.320.0970.06318.62
5.4.310.1130.08018.50
5.4.300.1200.07018.48
5.4.290.1170.06018.52
5.4.280.0870.06718.81
5.4.270.1070.05718.77
5.4.260.1100.06018.73
5.4.250.1000.06318.57
5.4.240.1200.06018.76
5.4.230.1070.04718.75
5.4.220.0900.05718.79
5.4.210.1030.04718.73
5.4.200.1000.04716.64
5.4.190.0970.05718.47
5.4.180.1000.07018.50
5.4.170.0970.06018.74
5.4.160.1430.06318.45
5.4.150.1370.05018.61
5.4.140.1330.04316.47
5.4.130.1000.05316.39
5.4.120.0970.05016.20
5.4.110.1570.05716.44
5.4.100.1400.07316.44
5.4.90.1600.05316.42
5.4.80.1570.05316.44
5.4.70.1500.06016.26
5.4.60.1270.05716.25
5.4.50.1300.05716.35
5.4.40.1170.05316.25
5.4.30.1170.06016.42
5.4.20.1270.04016.21
5.4.10.1170.05716.29
5.4.00.1300.03715.77
5.3.290.1300.06014.90
5.3.280.1300.05014.74
5.3.270.1530.06314.80
5.3.260.1000.06314.64
5.3.250.0900.06014.84
5.3.240.0900.05714.79
5.3.230.1400.05714.84
5.3.220.1270.04714.80
5.3.210.1230.05314.71
5.3.200.1270.04714.77
5.3.190.1270.05014.71
5.3.180.1300.05014.63
5.3.170.1100.07014.68
5.3.160.1100.07014.71
5.3.150.0900.06314.69
5.3.140.1430.07014.57
5.3.130.1300.05314.65
5.3.120.1400.06314.75
5.3.110.1170.07014.59
5.3.100.1270.04714.23
5.3.90.1230.06714.05
5.3.80.1200.07014.08
5.3.70.1430.06714.07
5.3.60.1400.05014.16
5.3.50.1400.06314.01
5.3.40.1000.06713.96
5.3.30.1000.04714.07
5.3.20.1000.05013.76
5.3.10.1270.04313.79
5.3.00.1300.07313.77
5.2.170.1300.04311.29
5.2.160.0830.05311.14
5.2.150.1030.05011.20
5.2.140.1000.04711.28
5.2.130.1000.04311.14
5.2.120.1030.03711.34
5.2.110.0800.04711.14
5.2.100.1070.03311.12
5.2.90.0970.04311.18
5.2.80.1000.04711.16
5.2.70.0930.04711.23
5.2.60.0930.04311.13
5.2.50.0730.04711.25
5.2.40.0730.04711.02
5.2.30.0770.04311.05
5.2.20.0770.04711.03
5.2.10.0770.04010.86
5.2.00.0730.06010.77
5.1.60.0800.04010.12
5.1.50.0670.03310.20
5.1.40.0600.04010.11
5.1.30.0700.04710.41
5.1.20.0630.04010.51
5.1.10.0670.03310.27
5.1.00.0900.03310.29
5.0.50.0370.0308.57
5.0.40.0370.0308.54
5.0.30.0400.0378.26
5.0.20.0400.0208.25
5.0.10.0400.0278.34
5.0.00.0400.0408.33
4.4.90.0370.0275.93
4.4.80.0330.0275.91
4.4.70.0500.0235.91
4.4.60.0530.0105.95
4.4.50.0400.0235.92
4.4.40.0430.0305.92
4.4.30.0430.0275.95
4.4.20.0370.0235.98
4.4.10.0330.0235.96
4.4.00.0370.0335.96
4.3.110.0270.0275.93
4.3.100.0370.0175.92
4.3.90.0330.0205.83
4.3.80.0300.0335.95
4.3.70.0370.0175.84
4.3.60.0370.0235.88
4.3.50.0370.0205.83
4.3.40.0400.0335.82
4.3.30.0170.0274.61
4.3.20.0170.0274.70
4.3.10.0200.0234.56
4.3.00.0000.0306.80

preferences:
143.9 ms | 1394 KiB | 7 Q