3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class element { /** * * @var string The HTML ID of the field. */ protected $id; /** * @var string The HTML tag to use when printing the element. */ protected $tag; /** * @var boolean Whether to include the indents and new line character when displaying. */ public $format = false; /** * @var array Any associated CSS files. */ public $css = array (); /** * @var array Attributes specific to this element. */ public $attributes = array (); /** * Default element constructor. */ function __construct ($id = false) { $this->id = $id; } /** * Increase the indents to be printed before the source code. * @return void No return value, the function actual prints the HTML to the screen. */ function incIndent () { global $indent; $indent++; } /** * Decrease the indents to be printed before the source code. * @return void No return value, the function actual prints the HTML to the screen. */ function decIndent () { global $indent; $indent--; } /** * Get the current number of indents. * @return int The current number of indents. */ function returnIndent () { global $indent; $r = ''; for ($i = 0; $i < $indent; $i++) $r .= " "; return $r; } /** * Get the string containing all the style information. * @return string The style string for the current element. */ protected function returnStyleString () { $result = ''; foreach ($this->css as $att => $val) $result .= $att.':'.$val.';'; if ($result <> '') return ' style="'.$result.'" '; else return ' '; } /** * Get the string containing all the attributes and their values. * @return string The string containing all the various attributes for the current element (excluding STYLE). */ protected function returnAttributeString () { $result = ''; foreach ($this->attributes as $att => $val) { $result .= $att.'="'.$val.'" '; } return $result; } /** * Get the opening tags for the element. * @return string The opening tag for the current element. */ protected function returnStartTag () { if (!isset ($this->tag)) throw new exception ('ERROR: element::tag is not set'); if (isset($this->id)) $id = 'id="'.$this->id.'"'; return sprintf ('<%s %s %s %s>', $this->tag, $id, $this->returnStyleString(), $this->returnAttributeString()); } /** * Get the closing tags for the element. * @return string The closing tags for the current element. */ protected function returnEndTag () { if (!isset ($this->tag)) throw new exception ('ERROR: element::tag is not set'); return sprintf ('</'.$this->tag.'>'); } /** * Display the opening tags for the element. * @return void No return value, the function actual prints the HTML to the screen. */ protected function displayStartTag () { if($this->format) { echo ($this->returnIndent () . $this->returnStartTag () . "\n"); $this->incIndent (); } else echo ($this->returnStartTag ()); } /** * Display the closing tags for the element. * @return void No return value, the function actual prints the HTML to the screen. */ protected function displayEndTag () { if($this->format) { echo ($this->returnIndent () . $this->returnEndTag () . "\n"); $this->decIndent (); } else echo ($this->returnEndTag ()); } /** * Display the element (including style and attributes). * @return void No return value, the function actual prints the HTML to the screen. */ function display () { if ($this->tag == '') throw new exception ('ERROR: element::tag is not set'); echo ($this->returnIndent ()); if($this->format) printf ("<%s%s%s />\n", $this->tag, $this->returnStyleString(), $this->returnAttributeString()); else printf ("<%s%s%s />", $this->tag, $this->returnStyleString(), $this->returnAttributeString()); } } class Text extends element { /** * @var string The text that the element will display. */ var $text; /** * Default constructor for the element. * @param string $text The text to display in the text element. */ function __construct ($text) { $this->text = $text; } /** * Display the text element. * @return void No return value, the function actual prints the HTML to the screen. */ function display () { echo ($this->text); } } abstract class block extends element { /** * @var array The elements that will be contained in the block. */ protected $elements = array (); /** * Add an element to the block. * @param mixed &$element The element to add to the block. * @return void No return value. */ function addElement (&$element, $position = -1) { if (is_a ($element, 'element')) { if(($position != -1) && ($position < count($this->elements))) { for($i = count($this->elements); $i > $position; $i--) $this->elements[$i] = $this->elements[$i-1]; $this->elements[$position] = $element; } else $this->elements[] = $element; } } /** * Display the block. * @return void No return value. */ function display () { $this->displayStartTag (); foreach ($this->elements as $e) $e->display (); $this->displayEndTag (); } } class div extends block { /** * @var string The HTML tag for a div. */ var $tag = 'div'; } $no_towns = new div (); $no_towns->attributes ['id'] = 'no_towns'; $no_towns->addElement ( new text ( "<i>No towns are viewable with your current permissions.</i>" ) ); $no_towns->colspan = 8; /*$no_towns->attributes ['style'] .= 'width:263px';*/ $no_towns->displayChanges = false; $no_towns->css ['display'] = 'none';

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.0060.00918.31
8.3.50.0130.00822.11
8.3.40.0100.00718.98
8.3.30.0090.00618.96
8.3.20.0140.00320.30
8.3.10.0030.00618.85
8.3.00.0030.00519.50
8.2.180.0110.01116.38
8.2.170.0030.01022.96
8.2.160.0110.00720.47
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0120.00326.16
8.2.120.0050.00319.77
8.2.110.0100.00020.41
8.2.100.0110.00018.03
8.2.90.0060.00319.60
8.2.80.0000.00819.35
8.2.70.0040.00417.75
8.2.60.0000.00819.78
8.2.50.0040.00418.07
8.2.40.0090.00020.97
8.2.30.0000.00718.12
8.2.20.0030.00517.81
8.2.10.0040.00418.09
8.2.00.0040.00417.82
8.1.280.0140.00725.92
8.1.270.0050.00320.65
8.1.260.0030.00526.35
8.1.250.0080.00028.09
8.1.240.0090.00022.29
8.1.230.0040.00722.37
8.1.220.0040.00417.74
8.1.210.0050.00319.01
8.1.200.0060.00317.48
8.1.190.0040.00417.48
8.1.180.0040.00418.10
8.1.170.0030.00618.76
8.1.160.0000.00718.95
8.1.150.0000.00718.99
8.1.140.0040.00417.51
8.1.130.0000.00717.93
8.1.120.0040.00417.44
8.1.110.0000.00817.53
8.1.100.0000.00717.46
8.1.90.0000.00717.42
8.1.80.0040.00417.50
8.1.70.0030.00517.53
8.1.60.0030.00617.55
8.1.50.0060.00317.62
8.1.40.0070.00017.39
8.1.30.0000.00817.71
8.1.20.0030.00517.69
8.1.10.0030.00517.57
8.1.00.0000.00817.32
8.0.300.0000.00820.01
8.0.290.0070.00016.88
8.0.280.0030.00518.55
8.0.270.0000.00717.32
8.0.260.0000.00717.26
8.0.250.0030.00317.13
8.0.240.0030.00317.09
8.0.230.0050.00316.91
8.0.220.0040.00416.92
8.0.210.0040.00417.01
8.0.200.0000.00716.97
8.0.190.0040.00416.99
8.0.180.0030.00917.04
8.0.170.0040.00417.05
8.0.160.0000.00717.05
8.0.150.0040.00416.84
8.0.140.0000.00716.93
8.0.130.0060.00013.49
8.0.120.0050.00317.07
8.0.110.0000.00717.07
8.0.100.0000.00716.89
8.0.90.0080.00017.06
8.0.80.0000.01616.97
8.0.70.0000.00717.09
8.0.60.0040.00416.98
8.0.50.0040.00416.88
8.0.30.0090.01517.15
8.0.20.0140.00517.40
8.0.10.0030.00517.03
8.0.00.0110.00716.80
7.4.330.0050.00015.14
7.4.320.0060.00316.54
7.4.300.0030.00316.70
7.4.290.0030.00316.58
7.4.280.0070.00016.57
7.4.270.0000.00716.62
7.4.260.0070.00016.49
7.4.250.0030.00616.39
7.4.240.0040.00416.70
7.4.230.0070.00016.77
7.4.220.0030.01616.60
7.4.210.0090.00616.61
7.4.200.0000.00716.74
7.4.160.0160.00016.55
7.4.150.0120.00617.40
7.4.140.0120.00917.86
7.4.130.0120.00716.75
7.4.120.0080.00816.71
7.4.110.0090.01316.82
7.4.100.0100.01116.71
7.4.90.0120.00616.69
7.4.80.0150.00819.39
7.4.70.0040.01416.65
7.4.60.0170.00016.55
7.4.50.0000.00516.39
7.4.40.0110.00516.39
7.4.30.0100.00716.59
7.4.00.0070.01015.14
7.3.330.0060.00013.41
7.3.320.0000.00613.48
7.3.310.0040.00416.38
7.3.300.0000.00816.39
7.3.290.0100.00616.50
7.3.280.0110.00816.46
7.3.270.0080.01117.40
7.3.260.0140.01016.50
7.3.250.0130.00616.49
7.3.240.0030.01316.43
7.3.230.0000.01716.58
7.3.210.0090.00916.55
7.3.200.0090.00819.39
7.3.190.0060.01316.49
7.3.180.0110.00416.46
7.3.170.0070.01116.59
7.3.160.0150.00616.57
7.2.330.0090.01316.81
7.2.320.0130.00616.80
7.2.310.0070.01016.73
7.2.300.0100.01016.54
7.2.290.0150.00316.67
7.2.60.0070.01016.89
7.2.00.0080.00419.33
7.1.200.0060.00615.83
7.1.100.0040.01118.34
7.1.70.0030.00517.22
7.1.60.0070.01819.32
7.1.50.0070.00716.67
7.1.00.0070.07322.31
7.0.200.0030.00716.63
7.0.140.0070.07022.08
7.0.100.0230.04719.95
7.0.90.0200.04020.04
7.0.80.0200.04019.96
7.0.70.0200.08019.95
7.0.60.0030.04720.01
7.0.50.0130.03020.43
7.0.40.0030.07320.14
7.0.30.0100.07720.14
7.0.20.0000.04720.18
7.0.10.0070.07720.14
7.0.00.0070.04020.14
5.6.280.0000.07720.91
5.6.250.0000.08020.80
5.6.240.0070.08020.73
5.6.230.0070.04020.73
5.6.220.0170.07020.67
5.6.210.0130.07720.67
5.6.200.0070.07321.13
5.6.190.0070.08021.08
5.6.180.0000.03721.14
5.6.170.0130.03721.02
5.6.160.0070.08321.10
5.6.150.0100.04020.99
5.6.140.0130.05321.07
5.6.130.0000.04721.13
5.6.120.0100.06321.00
5.6.110.0070.06721.15
5.6.100.0070.03721.17
5.6.90.0070.05020.98
5.6.80.0070.07020.55
5.6.70.0030.07320.48
5.6.60.0100.06320.44
5.6.50.0100.03020.60
5.6.40.0070.07320.52
5.6.30.0100.08020.43
5.6.20.0070.07320.44
5.6.10.0070.05320.57
5.6.00.0170.06020.40
5.5.380.0170.07320.55
5.5.370.0100.07320.50
5.5.360.0130.08320.44
5.5.350.0030.06720.48
5.5.340.0100.08320.89
5.5.330.0030.04020.89
5.5.320.0070.05720.88
5.5.310.0070.08320.97
5.5.300.0000.05720.87
5.5.290.0100.06320.70
5.5.280.0070.03720.93
5.5.270.0030.04320.84
5.5.260.0130.07320.93
5.5.250.0000.07320.75
5.5.240.0070.07720.18
5.5.230.0100.05320.20
5.5.220.0070.04320.29
5.5.210.0100.04020.19
5.5.200.0070.07320.17
5.5.190.0000.08720.34
5.5.180.0100.03720.29
5.5.160.0070.07320.29
5.5.150.0070.08020.28
5.5.140.0030.04020.28
5.5.130.0070.04320.16
5.5.120.0130.03720.30
5.5.110.0070.03720.30
5.5.100.0000.07320.21
5.5.90.0100.07720.19
5.5.80.0000.07720.22
5.5.70.0170.05720.12
5.5.60.0030.04720.07
5.5.50.0070.03720.13
5.5.40.0030.05320.09
5.5.30.0130.03020.14
5.5.20.0100.03320.05
5.5.10.0000.04320.09
5.5.00.0030.08020.14
5.4.450.0170.06019.55
5.4.440.0100.06319.54
5.4.430.0070.03719.37
5.4.420.0070.08019.45
5.4.410.0070.07319.32
5.4.400.0000.04019.13
5.4.390.0000.05019.05
5.4.380.0030.05018.88
5.4.370.0070.04319.04
5.4.360.0100.07019.13
5.4.350.0030.04719.03
5.4.340.0030.05718.90
5.4.320.0100.06319.05
5.4.310.0070.04019.03
5.4.300.0030.04019.06
5.4.290.0030.08319.18
5.4.280.0000.05019.04
5.4.270.0030.03718.90
5.4.260.0030.04318.87
5.4.250.0030.07319.13
5.4.240.0030.04018.87
5.4.230.0070.04718.93
5.4.220.0000.05018.96
5.4.210.0030.07019.08
5.4.200.0030.04319.09
5.4.190.0030.06319.11
5.4.180.0100.07319.11
5.4.170.0070.04319.23
5.4.160.0070.05718.82
5.4.150.0100.05718.90
5.4.140.0070.07016.46
5.4.130.0070.06716.46
5.4.120.0030.04316.38
5.4.110.0030.08016.43
5.4.100.0000.07716.56
5.4.90.0070.07016.40
5.4.80.0100.03016.56
5.4.70.0070.06316.55
5.4.60.0030.06016.44
5.4.50.0030.03316.42
5.4.40.0070.03016.46
5.4.30.0000.05016.50
5.4.20.0070.07016.51
5.4.10.0100.03716.53
5.4.00.0100.05715.98

preferences:
59.9 ms | 401 KiB | 5 Q