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, "=")!==false) { $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])-2); } var_dump($as); array_push($newlist, new Attribute($as[0], $as[1])); } var_dump($newlist); array_merge($this->attr, $newlist); } public function RemoveAttr($name = null) { if ($name === null) { $this->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 ). "'"))); } } $a = new Element("a"); $a->AddAttr(new Attribute("href", "http://twitter.nl")); $a->AddAttr(new Attribute("target", "_blank")); $span = new Element("span"); $span->AddAttr(new Attribute("style", array("color" => "orange","background-color" => "green"))); $span->Value("doei"); //Ads Doei in Span $span->AttrFromString("rel='none'"); //Adds Rel to None $img = new Element("img", true); //Makes Img Element $img->AddAttr(new Attribute("src", "https://www.google.nl/images/srpr/logo4w.png")); //Adds SRC $a->RemoveAttr("href"); //Removes Href Attribute $a->Value($span . NewLine. "hello world" .NewLine . $img); //Changes Inner Html of the A echo $a;

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.0130.00318.84
8.3.30.0130.00318.68
8.3.20.0060.00318.64
8.3.10.0130.00418.52
8.3.00.0060.00319.38
8.2.170.0090.00918.91
8.2.160.0090.00622.96
8.2.150.0080.00025.66
8.2.140.0170.00324.66
8.2.130.0000.00726.16
8.2.120.0000.00820.89
8.2.110.0030.00622.07
8.2.100.0040.00819.53
8.2.90.0000.00819.18
8.2.80.0040.00417.97
8.2.70.0040.00417.50
8.2.60.0030.00517.93
8.2.50.0040.00418.10
8.2.40.0000.00818.20
8.2.30.0050.00517.68
8.2.20.0070.00317.77
8.2.10.0040.00417.76
8.2.00.0060.00317.75
8.1.270.0050.00323.99
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0060.00317.48
8.1.230.0110.00017.70
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0070.00717.48
8.1.190.0000.00917.22
8.1.180.0040.00418.10
8.1.170.0040.00418.63
8.1.160.0040.00418.99
8.1.150.0050.00318.66
8.1.140.0000.00817.39
8.1.130.0000.00717.38
8.1.120.0000.00817.38
8.1.110.0050.00317.46
8.1.100.0070.00017.39
8.1.90.0040.00417.38
8.1.80.0000.00717.51
8.1.70.0030.00317.46
8.1.60.0040.00417.61
8.1.50.0090.00017.48
8.1.40.0000.00917.43
8.1.30.0050.00317.63
8.1.20.0060.00317.60
8.1.10.0040.00417.43
8.1.00.0000.01217.48
8.0.300.0060.00318.77
8.0.290.0030.00516.88
8.0.280.0080.00018.47
8.0.270.0000.00717.20
8.0.260.0030.00316.90
8.0.250.0000.00716.95
8.0.240.0040.00417.06
8.0.230.0000.00817.01
8.0.220.0000.00717.08
8.0.210.0040.00416.89
8.0.200.0000.00617.00
8.0.190.0000.00817.05
8.0.180.0000.00816.89
8.0.170.0060.00316.87
8.0.160.0000.00716.98
8.0.150.0040.00416.82
8.0.140.0070.00316.89
8.0.130.0000.00513.37
8.0.120.0080.00016.97
8.0.110.0080.00016.91
8.0.100.0000.00916.85
8.0.90.0000.00717.04
8.0.80.0070.01116.99
8.0.70.0040.00416.87
8.0.60.0030.00617.00
8.0.50.0100.00017.04
8.0.30.0160.00316.91
8.0.20.0080.01017.11
8.0.10.0040.00417.20
8.0.00.0110.00816.66
7.4.330.0000.00513.05
7.4.320.0000.00716.66
7.4.300.0030.00316.74
7.4.290.0050.00316.58
7.4.280.0060.00316.49
7.4.270.0050.00216.57
7.4.260.0050.00013.34
7.4.250.0050.00316.58
7.4.240.0040.00316.59
7.4.230.0050.00516.68
7.4.220.0070.01416.67
7.4.210.0070.01116.65
7.4.200.0040.00416.76
7.4.190.0040.00416.84
7.4.160.0000.01616.45
7.4.150.0110.01416.47
7.4.140.0140.00516.68
7.4.130.0110.00716.69
7.4.120.0140.00416.63
7.4.110.0130.01316.66
7.4.100.0100.01416.63
7.4.90.0000.01816.67
7.4.80.0120.00619.39
7.4.70.0100.01616.42
7.4.60.0000.01616.51
7.4.50.0050.00016.38
7.4.40.0070.01016.32
7.4.30.0070.01116.61
7.4.10.0070.01015.09
7.4.00.0120.00514.89
7.3.330.0000.00713.42
7.3.320.0000.00513.37
7.3.310.0040.00416.29
7.3.300.0030.00316.39
7.3.290.0060.00916.48
7.3.280.0110.00816.37
7.3.270.0030.01516.47
7.3.260.0150.00316.70
7.3.250.0100.01016.39
7.3.240.0060.01116.77
7.3.230.0130.00716.66
7.3.210.0130.00616.67
7.3.200.0130.00516.45
7.3.190.0060.01216.66
7.3.180.0100.00516.77
7.3.170.0110.01016.41
7.3.160.0060.01616.47
7.3.130.0050.01314.58
7.3.120.0030.01215.02
7.3.110.0150.00314.95
7.3.100.0040.01114.85
7.3.90.0070.00714.83
7.3.80.0070.00714.76
7.3.70.0000.01014.90
7.3.60.0030.01014.93
7.3.50.0040.01214.68
7.3.40.0040.01114.87
7.3.30.0030.01015.02
7.3.20.0030.01016.70
7.3.10.0000.01216.38
7.3.00.0090.00916.59
7.2.330.0120.00616.53
7.2.320.0040.01416.84
7.2.310.0070.01116.81
7.2.300.0140.00316.81
7.2.290.0110.00716.57
7.2.260.0070.01315.20
7.2.250.0070.01015.11
7.2.240.0100.00715.32
7.2.230.0000.01315.16
7.2.220.0100.00614.96
7.2.210.0110.00315.32
7.2.200.0080.00415.27
7.2.190.0090.00015.26
7.2.180.0100.01014.98
7.2.170.0080.00815.27
7.2.160.0060.00314.80
7.2.150.0100.00616.89
7.2.140.0160.00316.65
7.2.130.0030.00716.78
7.2.120.0110.00416.88
7.2.110.0040.01117.14
7.2.100.0100.00616.82
7.2.90.0040.00816.95
7.2.80.0090.00916.79
7.2.70.0030.01516.95
7.2.60.0030.01016.67
7.2.50.0120.00316.86
7.2.40.0040.01116.96
7.2.30.0000.01017.08
7.2.20.0060.00616.97
7.2.10.0030.01016.97
7.2.00.0090.00518.18
7.1.330.0030.00715.73
7.1.320.0090.00015.77
7.1.310.0040.00415.46
7.1.300.0000.01315.92
7.1.290.0060.01215.96
7.1.280.0030.01015.94
7.1.270.0040.00415.84
7.1.260.0060.01315.91
7.1.250.0030.00615.61
7.1.240.0040.00715.61
7.1.230.0040.00715.81
7.1.220.0110.00315.92
7.1.210.0100.00315.86
7.1.200.0060.00615.80
7.1.190.0060.00615.96
7.1.180.0060.00615.91
7.1.170.0000.01415.54
7.1.160.0130.00015.96
7.1.150.0130.00315.95
7.1.140.0000.01015.53
7.1.130.0030.00715.94
7.1.120.0000.01315.89
7.1.110.0070.00715.91
7.1.100.0050.00717.08
7.1.90.0040.00415.96
7.1.80.0030.01015.86
7.1.70.0030.00716.46
7.1.60.0070.01217.66
7.1.50.0050.01316.33
7.1.40.0000.01515.79
7.1.30.0000.00915.87
7.1.20.0080.00615.93
7.1.10.0100.00715.47
7.1.00.0050.03119.18
7.0.330.0030.01015.54
7.0.320.0030.00615.45
7.0.310.0030.01415.44
7.0.300.0120.00315.36
7.0.290.0040.00415.27
7.0.280.0090.00015.43
7.0.270.0080.00415.09
7.0.260.0040.01115.29
7.0.250.0000.00815.54
7.0.240.0040.00415.29
7.0.230.0040.00715.45
7.0.220.0030.00915.43
7.0.210.0070.00715.55
7.0.200.0030.00816.08
7.0.190.0040.00415.42
7.0.180.0040.00815.48
7.0.170.0110.00415.46
7.0.160.0100.00315.24
7.0.150.0080.00515.45
7.0.140.0070.04018.56
7.0.130.0090.00615.46
7.0.120.0070.03518.76
7.0.110.0030.00915.62
7.0.100.0080.03617.64
7.0.90.0050.04417.69
7.0.80.0070.02917.78
7.0.70.0110.04517.70
7.0.60.0210.02617.61
7.0.50.0050.03017.81
7.0.40.0110.04016.80
7.0.30.0030.04216.71
7.0.20.0050.04416.75
7.0.10.0070.02716.74
7.0.00.0060.04616.82
5.6.400.0100.00614.75
5.6.390.0000.01414.54
5.6.380.0040.00714.72
5.6.370.0070.01014.50
5.6.360.0070.00714.54
5.6.350.0000.00914.55
5.6.340.0070.00714.53
5.6.330.0000.01014.53
5.6.320.0060.00914.38
5.6.310.0070.00714.43
5.6.300.0110.00314.23
5.6.290.0000.01414.27
5.6.280.0070.03817.82
5.6.270.0060.01014.30
5.6.260.0070.00714.72
5.6.250.0080.02817.59
5.6.240.0120.02017.66
5.6.230.0130.04017.54
5.6.220.0070.02817.50
5.6.210.0050.04717.80
5.6.200.0050.04517.69
5.6.190.0070.03917.69
5.6.180.0080.04317.83
5.6.170.0040.03217.82
5.6.160.0060.04417.96
5.6.150.0070.04717.70
5.6.140.0100.03817.70
5.6.130.0120.03817.87
5.6.120.0100.04817.96
5.6.110.0090.02517.84
5.6.100.0110.02517.85
5.6.90.0080.04217.70
5.6.80.0130.03317.36
5.6.70.0080.04317.47
5.6.60.0050.04217.46
5.6.50.0020.04917.44
5.6.40.0070.03917.49
5.6.30.0080.04117.48
5.6.20.0050.02817.48
5.6.10.0050.02217.48
5.6.00.0080.03617.38
5.5.380.0110.04017.43
5.5.370.0140.03217.54
5.5.360.0060.02517.56
5.5.350.0040.03917.50
5.5.340.0100.04017.71
5.5.330.0030.04617.71
5.5.320.0100.02517.67
5.5.310.0070.03217.67
5.5.300.0170.03817.84
5.5.290.0100.04017.84
5.5.280.0030.04417.77
5.5.270.0080.04717.85
5.5.260.0070.03417.60
5.5.250.0090.03817.59
5.5.240.0130.03517.25
5.5.230.0030.03217.36
5.5.220.0050.02517.31
5.5.210.0040.03617.41
5.5.200.0090.02717.28
5.5.190.0070.03717.30
5.5.180.0030.03017.34
5.5.170.0090.00614.50
5.5.160.0050.04117.44
5.5.150.0030.02317.49
5.5.140.0030.02617.35
5.5.130.0100.04017.40
5.5.120.0070.03317.30
5.5.110.0120.04017.20
5.5.100.0100.03517.18
5.5.90.0030.04717.40
5.5.80.0050.04317.35
5.5.70.0020.04417.24
5.5.60.0100.03917.25
5.5.50.0080.03717.19
5.5.40.0050.02817.39
5.5.30.0020.04717.29
5.5.20.0050.04417.21
5.5.10.0070.02517.17
5.5.00.0050.04117.06
5.4.450.0070.03715.35
5.4.440.0050.04115.41
5.4.430.0080.04215.45
5.4.420.0060.04815.44
5.4.410.0090.02315.35
5.4.400.0030.04415.03
5.4.390.0060.04015.15
5.4.380.0030.04115.35
5.4.370.0120.03415.13
5.4.360.0090.04115.30
5.4.350.0120.03515.32
5.4.340.0070.04714.95
5.4.330.0030.00711.38
5.4.320.0090.03715.09
5.4.310.0050.02415.15
5.4.300.0040.03815.29
5.4.290.0050.04515.05
5.4.280.0020.04215.20
5.4.270.0060.03814.93
5.4.260.0070.03915.24
5.4.250.0050.02215.02
5.4.240.0020.04515.22
5.4.230.0020.02815.22
5.4.220.0030.04515.10
5.4.210.0100.03415.16
5.4.200.0030.04015.10
5.4.190.0080.03715.20
5.4.180.0040.02814.92
5.4.170.0060.04115.14
5.4.160.0030.04515.08
5.4.150.0050.03615.04
5.4.140.0110.03213.86
5.4.130.0050.04413.69
5.4.120.0100.03613.83
5.4.110.0050.03513.83
5.4.100.0050.03613.90
5.4.90.0050.04313.88
5.4.80.0080.04213.88
5.4.70.0030.03013.97
5.4.60.0000.03813.75
5.4.50.0050.04513.94
5.4.40.0030.03013.92
5.4.30.0050.03813.93
5.4.20.0110.03313.81
5.4.10.0050.02213.89
5.4.00.0090.03713.55
5.3.290.0070.03812.89
5.3.280.0090.04212.61
5.3.270.0040.03912.80
5.3.260.0030.04312.79
5.3.250.0100.03512.61
5.3.240.0130.01712.66
5.3.230.0070.04212.65
5.3.220.0050.03312.68
5.3.210.0040.02412.62
5.3.200.0030.04212.63
5.3.190.0050.03212.68
5.3.180.0050.02312.79
5.3.170.0030.04012.68
5.3.160.0100.03012.75
5.3.150.0070.03712.69
5.3.140.0030.04212.72
5.3.130.0110.03412.74
5.3.120.0050.04012.59
5.3.110.0070.02312.70
5.3.100.0060.04312.36
5.3.90.0070.04012.42
5.3.80.0070.02412.38
5.3.70.0050.04312.30
5.3.60.0040.02612.38
5.3.50.0040.02612.32
5.3.40.0050.02812.31
5.3.30.0070.04012.28
5.3.20.0100.02512.16
5.3.10.0070.03812.12
5.3.00.0080.03812.20

preferences:
43.29 ms | 400 KiB | 5 Q