3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Template { // Path var $path; // Handles var $handles = array(); // Vars var $v = array(); // Set templates path function, use relative, for explample: path('./html'); function SetPath ($path) { if (is_dir($path)) { $this->path = $path . '/'; return true; } else { die ('Template: path is not a relative path to an existent directory'); return false; } } // Loadfile Function; function LoadFile ($h) { if (empty($this->handles[$h])) { die ('Template: no filename specified for "'.$h.'"'); } $str = implode('', file($this->path.$this->handles[$h])); if (empty($str)) { die ('Template: template file ("'.$this->handles[$h].'") is empty'); } return $str; } // Set vars function, for exaple: setvars (array('onevar'=>'onevalue')); function SetVars ($arr) { while (list ($name, $value) = each ($arr)) { $this->v[0][$name] = $value; } return true; } // Set blockvars, for example: setbvars ('block.subblock', array('a'=>'b'); function SetBlockVars ($block, $arr) { if (strstr($block, '.')) { $all = explode ('.', $block); $count = count ($all) -1; $str = '$this->v[1]'; for ($i = 0; $i < $count; $i++) { $str .= '[\''.$all[$i].'\']'; eval ('$last = count ('.$str.') - 1;'); $str .= '['.$last.']'; } $str .= '[\''.$all[$count].'\'][] = $arr;'; eval ($str); } else { $this->v[1][$block][] = $arr; } return true; } // Set handles ( handle (array('name'=>'filename')) function Assign ($str) { $this->handles[$str] = $str.'.tpl'; return true; } // Compile code function compile ($code) { $code = str_replace ('\\', '\\\\', $code); $code = str_replace ('\'', '\\\'', $code); preg_match_all ('#\{([a-z0-9\-_.]+)\.([a-z0-9\-_]+)\}#is', $code, $bvars); $bvarscount = count ($bvars[0]); for ($i = 0; $i < $bvarscount; $i++) { $all = explode ('.', $bvars[1][$i]); $count = count ($all); $str = '$this->v[1]'; for ($ii = 0; $ii < $count; $ii++) { $str .= '[\''.$all[$ii].'\'][$_repeat_'.$all[$ii].']'; } $str .= '[\''.$bvars[2][$i].'\']'; $str = '\' . ( isset ('.$str.') ? '.$str.' : \'\' ) . \''; $replace[] = $str; $search[] = $bvars[0][$i]; } $code = str_replace ($search, $replace, $code); $code = preg_replace('#\{([a-z0-9\-_]*?)\}#is', '\' . ( ( isset($this->v[0][\'\1\']) ) ? $this->v[0][\'\1\'] : \'\' ) . \'', $code); $line = explode ("\n", $code); $lines = count ($line); $names = array (); for ($i = 0; $i < $lines; $i++) { $line[$i] = chop ($line[$i]); if (preg_match('#<!-- BEGIN (.*?) -->#', $line[$i], $temp)) { $blockname = $temp[1]; if (strstr ($blockname, '.')) { $blockarr = explode ('.', $blockname); $blocklen = count ($blockarr) -1; $ref = '$this->v[1]'; for ($x = 0; $x < $blocklen; $x++) { $ref .= '[\''.$blockarr[$x].'\'][$_repeat_'.$blockarr[$x].']'; } $ref .= '[\''.$blockarr[$x].'\']'; $line[$i] = '$_count_'.$blockarr[$x].' = ( isset ('.$ref.') ? count ('.$ref.') : 0);'; $line[$i] .= "\n".'for ($_repeat_'.$blockarr[$x].' = 0; $_repeat_'.$blockarr[$x].' < $_count_'.$blockarr[$x].'; $_repeat_'.$blockarr[$x].'++)'; $line[$i] .= "\n".'{ // BEGIN '.$blockname; } else { $ref = '$this->v[1][\''.$blockname.'\']'; $line[$i] = '$_count_'.$blockname.' = ( isset ('.$ref.') ? count ('.$ref.') : 0);'; $line[$i] .= "\n".'for ($_repeat_'.$blockname.' = 0; $_repeat_'.$blockname.' < $_count_'.$blockname.'; $_repeat_'.$blockname.'++)'; $line[$i] .= "\n".'{ // BEGIN '.$blockname; } } else if (preg_match('#<!-- END (.*?) -->#', $line[$i], $temp)) { $line[$i] = '} // END '.$temp[1]; } else { $line[$i] = 'print \''.$line[$i].'\'."\n";'; } } $code = implode ("\n", $line); return $code; } function Make ($handle) { $template = $this->LoadFile ($handle); $code = $this->compile ($template); eval ($code); /* highlight_string ("<?php\n".$code."\n?>"); */ return true; } } $tpl = new Template; $tpl->SetPath ('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)
8.3.60.0120.00916.62
8.3.50.0120.00316.22
8.3.40.0110.01118.81
8.3.30.0040.01118.62
8.3.20.0090.00620.24
8.3.10.0000.00821.81
8.3.00.0030.00617.72
8.2.180.0140.00718.92
8.2.170.0080.00822.96
8.2.160.0100.00320.52
8.2.150.0070.00024.18
8.2.140.0000.00824.66
8.2.130.0000.00821.13
8.2.120.0150.00426.35
8.2.110.0060.00321.12
8.2.100.0090.00318.09
8.2.90.0050.00319.08
8.2.80.0060.00318.04
8.2.70.0040.00417.63
8.2.60.0000.01017.93
8.2.50.0040.00418.10
8.2.40.0050.00320.39
8.2.30.0000.00819.18
8.2.20.0040.00418.10
8.2.10.0060.00318.02
8.2.00.0040.00418.08
8.1.280.0070.00725.92
8.1.270.0050.00323.87
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0040.00422.65
8.1.230.0070.00417.64
8.1.220.0040.00417.79
8.1.210.0090.00018.77
8.1.200.0030.00617.48
8.1.190.0000.00817.35
8.1.180.0030.00518.10
8.1.170.0000.00818.55
8.1.160.0000.00719.03
8.1.150.0000.00718.88
8.1.140.0030.00519.56
8.1.130.0030.00618.89
8.1.120.0040.00417.40
8.1.110.0050.00217.48
8.1.100.0000.00817.49
8.1.90.0040.00417.51
8.1.80.0000.00817.54
8.1.70.0000.00717.39
8.1.60.0030.00517.72
8.1.50.0040.00417.62
8.1.40.0040.00417.66
8.1.30.0030.00517.68
8.1.20.0040.00417.76
8.1.10.0000.00817.68
8.1.00.0040.00417.62
8.0.300.0050.00318.77
8.0.290.0030.00716.88
8.0.280.0030.00318.36
8.0.270.0040.00417.31
8.0.260.0000.00716.93
8.0.250.0030.00317.03
8.0.240.0070.00016.99
8.0.230.0080.00017.00
8.0.220.0000.00716.99
8.0.210.0000.00717.00
8.0.200.0000.00817.07
8.0.190.0060.00316.96
8.0.180.0100.00017.03
8.0.170.0000.00717.02
8.0.160.0040.00416.89
8.0.150.0070.00017.00
8.0.140.0040.00416.97
8.0.130.0000.00813.39
8.0.120.0000.00817.00
8.0.110.0070.00016.91
8.0.100.0070.00016.93
8.0.90.0080.00017.03
8.0.80.0090.00917.11
8.0.70.0040.00417.09
8.0.60.0050.00316.94
8.0.50.0000.00817.11
8.0.30.0090.00917.04
8.0.20.0140.00617.42
8.0.10.0040.00416.93
8.0.00.0090.00916.82
7.4.330.0000.00515.55
7.4.320.0000.00616.62
7.4.300.0030.00316.52
7.4.290.0000.00716.51
7.4.280.0060.00316.70
7.4.270.0040.00416.66
7.4.260.0070.00013.37
7.4.250.0070.00016.55
7.4.240.0040.00416.62
7.4.230.0040.00416.80
7.4.220.0140.01116.63
7.4.210.0080.01216.81
7.4.200.0050.00216.76
7.4.160.0050.01116.48
7.4.150.0030.01617.40
7.4.140.0120.00717.86
7.4.130.0040.01816.67
7.4.120.0110.00916.49
7.4.110.0060.01516.57
7.4.100.0100.00716.71
7.4.90.0170.00716.56
7.4.80.0130.00319.39
7.4.70.0130.00316.73
7.4.60.0100.00616.61
7.4.50.0030.01316.63
7.4.40.0060.01116.56
7.4.30.0060.01616.62
7.4.00.0110.00314.94
7.3.330.0050.00013.46
7.3.320.0000.00613.36
7.3.310.0000.00716.43
7.3.300.0030.00316.30
7.3.290.0030.00316.27
7.3.280.0090.00816.38
7.3.270.0120.00617.40
7.3.260.0200.01516.48
7.3.250.0140.00416.37
7.3.240.0100.00716.36
7.3.230.0150.00316.32
7.3.210.0110.00616.36
7.3.200.0070.01016.43
7.3.190.0070.01016.63
7.3.180.0080.00816.39
7.3.170.0090.00616.65
7.3.160.0080.00816.62
7.2.330.0030.01416.57
7.2.320.0130.00416.66
7.2.310.0030.01416.68
7.2.300.0180.00316.69
7.2.290.0120.00316.48
7.2.60.0040.01216.86
7.2.00.0160.00419.07
7.1.200.0230.01015.53
7.1.100.0030.00818.11
7.1.70.0060.00617.21
7.1.60.0140.01035.20
7.1.50.0140.01134.83
7.1.40.0200.00734.39
7.1.30.0180.00934.45
7.1.20.0160.01034.40
7.1.10.0000.01216.62
7.1.00.0030.01016.82
7.0.200.0080.00316.91
7.0.190.0000.01116.76
7.0.180.0030.00916.01
7.0.170.0090.00316.16
7.0.160.0030.01016.30
7.0.150.0060.00616.13
7.0.140.0060.00616.27
7.0.130.0060.00616.34
7.0.120.0030.01116.43
7.0.110.0060.00616.06
7.0.100.0090.00316.21
7.0.90.0060.00616.33
7.0.80.0060.00616.39
7.0.70.0060.00616.50
7.0.60.0000.01516.12
7.0.50.0060.00616.36
7.0.40.0040.00816.33
7.0.30.0070.00716.56
7.0.20.0040.00716.41
7.0.10.0080.00416.54
7.0.00.0050.00516.41

preferences:
53.69 ms | 401 KiB | 5 Q