3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Element { private $single, $tag, $value, $attr=array(); public function __construct($tag, $single = false) { $this->tag = $tag; $this->single = $single; } public function Value($value) { $this->value = $value; } public function AddAttr($attr, $list = false) { if ($list) { array_merge($this->attr, $list); } else { array_push($this->attr, $attr); } } public function GetAttr($name = null) { if ($i === null) { return $this->attr; } else { foreach($this->attr as $try) { if ($try->Name() === $name) { return $this->attr[$name]; } } return new Attribute(""); } } public function SetAttr($name, $value) { $exist = false; foreach($this->attr as $try) { if ($try->Name() === $name) { $try->Value($value); $exist = true; } } if (!$exist) { array_push($this->attr, new Attr($name, $value)); } } public function AttrFromString($string) { $items = explode(" ", $string); $newlist = array(); foreach($items as $yes) { if (strpos($yes, "=")) { $as = explode('=', $yes); } else { $as[0] = $yes; $as[1] = ""; } if (substr($as[1], 0,1) == "'" || substr($as[1], 0,1) == '"') { $as[1] = substr($as[1],1,strlen($as)-1); } array_push($newlist, new Attribute($as[0], $as[1])); } array_merge($this->attr, $newlist); } public function RemoveAttr($name = null) { if ($name === null) { $attr = array(); } else { for($i = 0; $i < count($this->attr); $i++) { if ($this->attr[$i]->Name() === $name) { unset($this->attr[$i]); } } } } public function __toString() { return "<" . $this->tag . " " . implode(" ",$this->attr) . ($this->single ? (!empty($this->value) ? "value='" . $this->value ."'" : "" ). "/>" : '>' . $this->value . '</'.$this->tag.'>'); } } define('NewLine', "<br />"); define('DocType', '<!DOCTYPE html>'); class Attribute { private $name, $value; public function __construct($name, $value = "") { $this->name = $name; $this->value = $value; } public function Name($name = null) { if ($name === null) { return $this->name; } else { $this->name = $name; } } public function Value($value = null) { if ($value === null) { return $this->value; } else { $this->value = $value; } } public function __toString() { if (is_array($this->value)) { $code = ""; foreach ($this->value as $key => $value) { $code .= $key . ":" . $value . ';'; } } return ($this->value === true ? $this->name : ($this->value === false ? "" : ($this->value === "" ? $this->name : $this->name . "='".(is_array($this->value) ? $code : $this->value ). "'"))); } } $element = new Element("a"); $element->AddAttr(new Attribute("href", "http://google.nl")); $element->AddAttr(new Attribute("target", "_blank")); $element2 = new Element("span"); $element2->AddAttr(new Attribute("style", array("color" => "orange","background-color" => "green"))); $element2->Value("doei"); $element2->AttrFromString("required"); $element3 = new Element("img", true); $element->SetAttr("href", "http://twitter.com"); $element3->AddAttr(new Attribute("src", "https://si0.twimg.com/profile_images/3439429669/c2c9d02095be44d026d358e0a39bced0_normal.jpeg")); $element->RemoveAttr("href"); $element->Value($element2 . NewLine. "hoi" .NewLine . $element3); echo $element;

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.40.0000.01418.71
8.3.30.0140.00018.60
8.3.20.0050.00318.80
8.3.10.0040.00420.79
8.3.00.0080.00023.51
8.2.170.0110.00422.96
8.2.160.0100.00320.52
8.2.150.0080.00024.18
8.2.140.0030.00524.66
8.2.130.0040.00426.16
8.2.120.0030.00617.60
8.2.110.0030.00620.70
8.2.100.0060.00617.84
8.2.90.0040.00419.30
8.2.80.0030.00617.97
8.2.70.0090.00017.63
8.2.60.0050.00317.93
8.2.50.0080.00018.07
8.2.40.0040.00418.22
8.2.30.0000.00721.19
8.2.20.0040.00417.63
8.2.10.0040.00417.80
8.2.00.0000.00717.64
8.1.270.0060.00322.28
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0060.00322.33
8.1.230.0120.00021.02
8.1.220.0040.00418.77
8.1.210.0080.00019.09
8.1.200.0000.00917.25
8.1.190.0050.00317.53
8.1.180.0050.00318.10
8.1.170.0030.00518.84
8.1.160.0000.00818.83
8.1.150.0000.00718.66
8.1.140.0040.00417.39
8.1.130.0000.00917.90
8.1.120.0050.00317.45
8.1.110.0040.00417.39
8.1.100.0050.00317.38
8.1.90.0040.00417.54
8.1.80.0040.00417.46
8.1.70.0040.00417.38
8.1.60.0130.00017.54
8.1.50.0000.00717.36
8.1.40.0040.00417.57
8.1.30.0000.00817.51
8.1.20.0040.00417.70
8.1.10.0000.00817.36
8.1.00.0070.00017.36
8.0.300.0040.00419.85
8.0.290.0070.00017.30
8.0.280.0040.00418.43
8.0.270.0040.00417.29
8.0.260.0030.00316.82
8.0.250.0040.00416.97
8.0.240.0040.00417.09
8.0.230.0070.00016.96
8.0.220.0000.00717.01
8.0.210.0030.00517.06
8.0.200.0090.00017.00
8.0.190.0040.00316.92
8.0.180.0000.00717.04
8.0.170.0000.00817.03
8.0.160.0040.00416.97
8.0.150.0040.00416.82
8.0.140.0000.00717.00
8.0.130.0000.00613.41
8.0.120.0040.00416.84
8.0.110.0000.00816.84
8.0.100.0070.00017.09
8.0.90.0000.00816.81
8.0.80.0160.00517.04
8.0.70.0070.00017.02
8.0.60.0050.00317.01
8.0.50.0000.00816.93
8.0.30.0100.00917.09
8.0.20.0130.00617.40
8.0.10.0000.00917.18
8.0.00.0090.00816.72
7.4.330.0030.00314.77
7.4.320.0030.00316.62
7.4.300.0030.00316.74
7.4.290.0000.00816.62
7.4.280.0000.00716.57
7.4.270.0030.00316.46
7.4.260.0000.00713.35
7.4.250.0040.00416.66
7.4.240.0040.00416.54
7.4.230.0030.00316.67
7.4.220.0080.00816.54
7.4.210.0070.01116.67
7.4.200.0070.00016.63
7.4.190.0000.00816.87
7.4.160.0030.01416.82
7.4.150.0030.01717.40
7.4.140.0120.00917.86
7.4.130.0090.00816.65
7.4.120.0120.00516.63
7.4.110.0060.01216.54
7.4.100.0120.00916.59
7.4.90.0140.01016.52
7.4.80.0100.01019.39
7.4.70.0150.00316.67
7.4.60.0080.01116.54
7.4.50.0070.00016.42
7.4.40.0070.01122.77
7.4.30.0070.01316.39
7.4.00.0070.00915.04
7.3.330.0030.00313.23
7.3.320.0030.00313.47
7.3.310.0000.00816.46
7.3.300.0070.00016.41
7.3.290.0100.00316.45
7.3.280.0100.00916.43
7.3.270.0170.00017.40
7.3.260.0090.01018.24
7.3.250.0080.00916.75
7.3.240.0070.01016.40
7.3.230.0140.00916.57
7.3.210.0180.00316.36
7.3.200.0090.00919.39
7.3.190.0110.00616.51
7.3.180.0030.01316.76
7.3.170.0120.00916.80
7.3.160.0060.00916.48
7.3.120.0060.01114.85
7.3.110.0070.01214.83
7.3.100.0060.01115.00
7.3.90.0030.01014.91
7.3.80.0060.01014.88
7.3.70.0070.00714.78
7.3.60.0020.01314.85
7.3.50.0050.01015.03
7.3.40.0050.00814.75
7.3.30.0100.00614.64
7.3.20.0060.00716.73
7.3.10.0060.00516.78
7.3.00.0070.00516.56
7.2.330.0120.00616.84
7.2.320.0170.00316.97
7.2.310.0170.00716.48
7.2.300.0060.01116.78
7.2.290.0060.01116.89
7.2.250.0080.01315.32
7.2.240.0110.01015.36
7.2.230.0020.01415.09
7.2.220.0020.01015.15
7.2.210.0080.01115.15
7.2.200.0090.00415.34
7.2.190.0100.00615.07
7.2.180.0080.00714.98
7.2.170.0080.00415.21
7.2.130.0100.00616.94
7.2.120.0000.01116.85
7.2.110.0000.01017.15
7.2.100.0060.01016.94
7.2.90.0080.00817.07
7.2.80.0060.00616.92
7.2.70.0070.01017.13
7.2.60.0030.01016.98
7.2.50.0040.00717.09
7.2.40.0000.01617.06
7.2.30.0060.00917.01
7.2.20.0090.00316.75
7.2.10.0120.00316.89
7.2.00.0030.01018.23
7.1.330.0040.01115.72
7.1.320.0030.01315.73
7.1.310.0020.01615.86
7.1.300.0070.00715.74
7.1.290.0000.01315.91
7.1.280.0040.00915.88
7.1.270.0080.00815.69
7.1.260.0050.00715.79
7.1.250.0070.01015.75
7.1.240.0050.00515.43
7.1.230.0000.01115.79
7.1.220.0030.01315.67
7.1.210.0100.00615.52
7.1.200.0030.00715.91
7.1.190.0100.00515.83
7.1.180.0110.00315.92
7.1.170.0110.00315.74
7.1.160.0060.00615.90
7.1.150.0030.00615.50
7.1.140.0040.00415.95
7.1.130.0030.00815.92
7.1.120.0000.01215.81
7.1.110.0100.00715.70
7.1.100.0080.00216.95
7.1.90.0040.01215.96
7.1.80.0070.00315.69
7.1.70.0040.00916.53
7.1.60.0020.01317.56
7.1.50.0050.01216.32
7.1.40.0000.01215.83
7.1.30.0100.00315.85
7.1.20.0030.00616.02
7.1.10.0030.00715.63
7.1.00.0030.02019.04
7.0.330.0120.00315.17
7.0.320.0030.00715.23
7.0.310.0050.00515.36
7.0.300.0070.00715.42
7.0.290.0040.00815.09
7.0.280.0040.01115.13
7.0.270.0030.01015.27
7.0.260.0030.00915.02
7.0.250.0100.00315.38
7.0.240.0100.00615.40
7.0.230.0080.00315.39
7.0.220.0080.00415.32
7.0.210.0060.00615.32
7.0.200.0060.00416.19
7.0.190.0070.00715.37
7.0.180.0090.00015.45
7.0.170.0070.00715.43
7.0.160.0030.00715.33
7.0.150.0060.00615.10
7.0.140.0100.03518.74
7.0.130.0080.00415.05
7.0.120.0030.01015.30
7.0.110.0000.01315.30
7.0.100.0030.04317.64
7.0.90.0110.03817.77
7.0.80.0050.02317.57
7.0.70.0070.04017.61
7.0.60.0050.03817.70
7.0.50.0090.04318.00
7.0.40.0070.04116.74
7.0.30.0080.04516.70
7.0.20.0100.02216.64
7.0.10.0100.04516.61
7.0.00.0090.03416.64
5.6.380.0040.00714.27
5.6.370.0110.00314.51
5.6.360.0040.01214.14
5.6.350.0050.00514.42
5.6.340.0040.00814.22
5.6.330.0060.00914.64
5.6.320.0030.00714.35
5.6.310.0030.00614.71
5.6.300.0030.00614.32
5.6.290.0070.00714.79
5.6.280.0040.00714.45
5.6.270.0030.01214.42
5.6.260.0110.00314.46
5.6.250.0050.02217.66
5.6.240.0080.01817.53
5.6.230.0060.03317.60
5.6.220.0070.04817.45
5.6.210.0060.03917.66
5.6.200.0100.03817.67
5.6.190.0070.04017.74
5.6.180.0050.04517.80
5.6.170.0030.04517.75
5.6.160.0030.04517.71
5.6.150.0050.04917.72
5.6.140.0050.04617.98
5.6.130.0100.03317.81
5.6.120.0030.05117.91
5.6.110.0090.03917.62
5.6.100.0050.02817.96
5.6.90.0030.03117.78
5.6.80.0140.02617.44
5.6.70.0070.03917.36
5.6.60.0120.03217.49
5.6.50.0120.03517.41
5.6.40.0080.02417.48
5.6.30.0110.03617.40
5.6.20.0070.03017.42
5.6.10.0080.04217.31
5.6.00.0050.03517.41
5.5.380.0030.03615.89
5.5.370.0020.02316.04
5.5.360.0080.03015.81
5.5.350.0100.03515.83
5.5.340.0100.03716.04
5.5.330.0070.04516.00
5.5.320.0050.04116.07
5.5.310.0050.04416.08
5.5.300.0080.04516.13
5.5.290.0070.03716.06
5.5.280.0050.04316.21
5.5.270.0050.02516.03
5.5.260.0050.02416.07
5.5.250.0070.03916.08
5.5.240.0070.04215.84
5.5.230.0050.02115.85
5.5.220.0060.02815.80
5.5.210.0040.04015.82
5.5.200.0050.02415.78
5.5.190.0020.03515.89
5.5.180.0090.02415.66
5.5.170.0040.00911.34
5.5.160.0050.03815.72
5.5.150.0050.02415.83
5.5.140.0060.02015.71
5.5.130.0090.04215.61
5.5.120.0070.03015.69
5.5.110.0050.03815.70
5.5.100.0070.02215.59
5.5.90.0050.03515.52
5.5.80.0050.04415.56
5.5.70.0050.02515.74
5.5.60.0070.04015.69
5.5.50.0050.04515.58
5.5.40.0050.04215.60
5.5.30.0080.03415.70
5.5.20.0070.04015.69
5.5.10.0110.02215.76
5.5.00.0090.03915.62
5.4.450.0070.03815.32
5.4.440.0070.02615.36
5.4.430.0050.03915.29
5.4.420.0030.02915.35
5.4.410.0060.03915.21
5.4.400.0000.02115.09
5.4.390.0080.03415.01
5.4.380.0080.04015.07
5.4.370.0040.02115.18
5.4.360.0090.03615.16
5.4.350.0030.03315.02
5.4.340.0020.03615.08
5.4.330.0000.01010.96
5.4.320.0040.04114.98
5.4.310.0040.03515.11
5.4.300.0070.02415.14
5.4.290.0070.03714.95
5.4.280.0100.03615.06
5.4.270.0030.04215.08
5.4.260.0100.03814.93
5.4.250.0070.02014.97
5.4.240.0030.03714.93
5.4.230.0110.03514.87
5.4.220.0050.04015.03
5.4.210.0050.02315.13
5.4.200.0050.03714.91
5.4.190.0070.04015.07
5.4.180.0050.04214.83
5.4.170.0080.03314.90
5.4.160.0000.03314.77
5.4.150.0050.02715.00
5.4.140.0050.04213.78
5.4.130.0070.03713.57
5.4.120.0030.04213.84
5.4.110.0110.03413.85
5.4.100.0130.03313.88
5.4.90.0100.02613.89
5.4.80.0130.03013.71
5.4.70.0040.03913.88
5.4.60.0070.03013.84
5.4.50.0080.04013.92
5.4.40.0050.02313.64
5.4.30.0050.02013.87
5.4.20.0080.02213.85
5.4.10.0050.02513.71
5.4.00.0100.03913.59
5.3.290.0040.03912.73
5.3.280.0050.02012.51
5.3.270.0070.02512.73
5.3.260.0080.02212.64
5.3.250.0040.03912.70
5.3.240.0070.03912.64
5.3.230.0050.04012.73
5.3.220.0060.02412.60
5.3.210.0130.03712.66
5.3.200.0070.03812.68
5.3.190.0120.03712.44
5.3.180.0090.02412.79
5.3.170.0080.04012.70
5.3.160.0090.03712.71
5.3.150.0070.03612.60
5.3.140.0080.03212.78
5.3.130.0010.02312.71
5.3.120.0040.04312.67
5.3.110.0070.03412.71
5.3.100.0030.04512.43
5.3.90.0090.03212.41
5.3.80.0030.03712.33
5.3.70.0100.01812.36
5.3.60.0050.03612.44
5.3.50.0060.03812.34
5.3.40.0100.02012.30
5.3.30.0060.02112.35
5.3.20.0030.04412.08
5.3.10.0030.03312.08
5.3.00.0050.03111.98

preferences:
35.44 ms | 400 KiB | 5 Q