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 { foreach($this->attr as $try) { if ($try->Name() === $name) { unset($try); } } } } 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.60.0140.00716.88
8.3.50.0140.00717.55
8.3.40.0120.00318.68
8.3.30.0100.00618.59
8.3.20.0080.00018.57
8.3.10.0060.00320.53
8.3.00.0080.00019.13
8.2.180.0070.01416.50
8.2.170.0090.00622.96
8.2.160.0040.01120.98
8.2.150.0050.00524.18
8.2.140.0090.00024.66
8.2.130.0040.00426.16
8.2.120.0040.00420.89
8.2.110.0080.00421.11
8.2.100.0120.00017.91
8.2.90.0090.00019.36
8.2.80.0030.00517.97
8.2.70.0000.00817.50
8.2.60.0050.00317.93
8.2.50.0030.00618.07
8.2.40.0040.00418.22
8.2.30.0040.00418.00
8.2.20.0000.00817.74
8.2.10.0080.00017.64
8.2.00.0100.00017.67
8.1.280.0120.00625.92
8.1.270.0000.00724.66
8.1.260.0040.00426.35
8.1.250.0110.00428.09
8.1.240.0090.00021.25
8.1.230.0120.00017.52
8.1.220.0040.00417.76
8.1.210.0000.00818.77
8.1.200.0060.00317.35
8.1.190.0000.00817.23
8.1.180.0080.00018.10
8.1.170.0050.00318.94
8.1.160.0080.00018.96
8.1.150.0000.00818.61
8.1.140.0000.00817.42
8.1.130.0000.00717.84
8.1.120.0050.00317.48
8.1.110.0040.00417.47
8.1.100.0030.00517.52
8.1.90.0000.00717.49
8.1.80.0000.00817.40
8.1.70.0030.00617.35
8.1.60.0030.00617.57
8.1.50.0030.00517.39
8.1.40.0080.00317.55
8.1.30.0000.00817.68
8.1.20.0030.00517.70
8.1.10.0000.00817.37
8.1.00.0040.00417.39
8.0.300.0040.00418.77
8.0.290.0020.00516.88
8.0.280.0040.00418.48
8.0.270.0000.00817.27
8.0.260.0070.00016.92
8.0.250.0030.00617.11
8.0.240.0000.00816.93
8.0.230.0000.00716.96
8.0.220.0030.00716.95
8.0.210.0070.00017.03
8.0.200.0080.00017.00
8.0.190.0040.00416.95
8.0.180.0090.00016.92
8.0.170.0040.00416.88
8.0.160.0050.00216.88
8.0.150.0040.00416.80
8.0.140.0000.01016.84
8.0.130.0000.00613.45
8.0.120.0030.00516.96
8.0.110.0040.00417.00
8.0.100.0040.00416.98
8.0.90.0070.00016.94
8.0.80.0080.00816.95
8.0.70.0000.00716.91
8.0.60.0040.00416.92
8.0.50.0000.00816.96
8.0.30.0100.00917.10
8.0.20.0120.00716.99
8.0.10.0030.00517.12
8.0.00.0070.01116.87
7.4.330.0020.00313.05
7.4.320.0060.00016.59
7.4.300.0060.00016.69
7.4.290.0040.00416.61
7.4.280.0000.00916.49
7.4.270.0030.00316.58
7.4.260.0050.00013.47
7.4.250.0060.00316.60
7.4.240.0050.00216.70
7.4.230.0030.00316.63
7.4.220.0110.00616.59
7.4.210.0090.00716.64
7.4.200.0070.00016.71
7.4.190.0000.00716.45
7.4.160.0030.01716.57
7.4.150.0120.00616.64
7.4.140.0120.00716.56
7.4.130.0050.01216.75
7.4.120.0080.01016.59
7.4.110.0130.00316.59
7.4.100.0090.00916.61
7.4.90.0280.00816.71
7.4.80.0070.01619.39
7.4.70.0110.00716.57
7.4.60.0040.01316.64
7.4.50.0040.00416.55
7.4.40.0060.00916.45
7.4.30.0080.00816.73
7.4.10.0040.01414.84
7.4.00.0070.01014.98
7.3.330.0000.00613.23
7.3.320.0030.00313.31
7.3.310.0000.00716.41
7.3.300.0000.00716.41
7.3.290.0040.01116.41
7.3.280.0070.01116.39
7.3.270.0030.01316.67
7.3.260.0060.01216.35
7.3.250.0160.00316.38
7.3.240.0140.01016.40
7.3.230.0100.00616.50
7.3.210.0050.01216.55
7.3.200.0120.00416.48
7.3.190.0190.00316.71
7.3.180.0070.01016.41
7.3.170.0100.01016.51
7.3.160.0090.00616.49
7.3.130.0150.00314.71
7.3.120.0060.01114.94
7.3.110.0060.01015.15
7.3.100.0030.01214.81
7.3.90.0040.01115.03
7.3.80.0030.01014.89
7.3.70.0000.01214.98
7.3.60.0090.00615.01
7.3.50.0060.00914.95
7.3.40.0000.00815.01
7.3.30.0080.00414.98
7.3.20.0060.00616.54
7.3.10.0040.00816.68
7.3.00.0080.00416.48
7.2.330.0030.01916.91
7.2.320.0060.01216.95
7.2.310.0110.00716.82
7.2.300.0100.00716.81
7.2.290.0170.00016.81
7.2.260.0100.01315.24
7.2.250.0100.01015.32
7.2.240.0060.00915.16
7.2.230.0040.01115.10
7.2.220.0060.01215.20
7.2.210.0000.01215.45
7.2.200.0060.01015.25
7.2.190.0040.00715.19
7.2.180.0060.00915.03
7.2.170.0040.00915.32
7.2.160.0030.01415.12
7.2.150.0110.00317.02
7.2.140.0060.01117.04
7.2.130.0070.00716.88
7.2.120.0070.00316.83
7.2.110.0030.00716.85
7.2.100.0120.00316.88
7.2.90.0030.01016.82
7.2.80.0060.00916.80
7.2.70.0000.00916.73
7.2.60.0080.00417.08
7.2.50.0110.00717.00
7.2.40.0030.01016.89
7.2.30.0000.01717.02
7.2.20.0030.00917.01
7.2.10.0090.00616.88
7.2.00.0130.00616.96
7.1.330.0060.00615.72
7.1.320.0140.00316.09
7.1.310.0040.00415.91
7.1.300.0070.00715.61
7.1.290.0070.00315.89
7.1.280.0070.01015.78
7.1.270.0060.00615.53
7.1.260.0000.01115.61
7.1.250.0040.00815.91
7.1.240.0030.00616.01
7.1.230.0070.00715.64
7.1.220.0060.00615.64
7.1.210.0070.00715.67
7.1.200.0020.00815.71
7.1.190.0050.00515.84
7.1.180.0070.00715.79
7.1.170.0080.00315.81
7.1.160.0050.00315.77
7.1.150.0070.01115.69
7.1.140.0000.01715.93
7.1.130.0080.00415.54
7.1.120.0040.01115.90
7.1.110.0080.00415.64
7.1.100.0090.00915.85
7.1.90.0040.00815.89
7.1.80.0000.01515.97
7.1.70.0070.00716.51
7.1.60.0050.00716.53
7.1.50.0100.00616.42
7.1.40.0030.01015.88
7.1.30.0040.00715.97
7.1.20.0070.01015.97
7.1.10.0060.01215.96
7.1.00.0030.04218.98
7.0.330.0040.01115.40
7.0.320.0030.01015.63
7.0.310.0070.00715.41
7.0.300.0000.01115.49
7.0.290.0000.00915.55
7.0.280.0060.00815.16
7.0.270.0000.01315.14
7.0.260.0110.00315.49
7.0.250.0050.01215.52
7.0.240.0000.01715.57
7.0.230.0100.00315.40
7.0.220.0050.00815.57
7.0.210.0090.00615.53
7.0.200.0070.01016.17
7.0.190.0040.00715.39
7.0.180.0060.00615.20
7.0.170.0060.00615.59
7.0.160.0030.01015.42
7.0.150.0030.01115.30
7.0.140.0050.03818.74
7.0.130.0040.00415.45
7.0.120.0000.03918.64
7.0.110.0070.00715.53
7.0.100.0090.02217.78
7.0.90.0070.03617.60
7.0.80.0060.04317.62
7.0.70.0020.03717.76
7.0.60.0050.02417.90
7.0.50.0070.03018.03
7.0.40.0030.02916.84
7.0.30.0090.02416.81
7.0.20.0090.02516.71
7.0.10.0030.03316.82
7.0.00.0050.03516.71
5.6.400.0000.01314.56
5.6.390.0030.00714.73
5.6.380.0050.00514.92
5.6.370.0060.00614.86
5.6.360.0030.01414.67
5.6.350.0080.00614.78
5.6.340.0060.00914.71
5.6.330.0030.01114.46
5.6.320.0110.00414.57
5.6.310.0030.01414.50
5.6.300.0050.00514.62
5.6.290.0090.00014.57
5.6.280.0020.04417.64
5.6.270.0060.00614.36
5.6.260.0040.01114.54
5.6.250.0050.03017.70
5.6.240.0080.04517.64
5.6.230.0070.04217.78
5.6.220.0130.03517.54
5.6.210.0020.03417.78
5.6.200.0030.03217.83
5.6.190.0070.03017.80
5.6.180.0100.02317.82
5.6.170.0050.03017.69
5.6.160.0050.02717.78
5.6.150.0070.02417.69
5.6.140.0050.02717.87
5.6.130.0100.01817.80
5.6.120.0050.03617.86
5.6.110.0090.04017.74
5.6.100.0110.03117.88
5.6.90.0070.03017.82
5.6.80.0030.02817.34
5.6.70.0050.03417.46
5.6.60.0050.02617.41
5.6.50.0030.02917.59
5.6.40.0050.02617.38
5.6.30.0030.04517.41
5.6.20.0050.02417.43
5.6.10.0070.02617.48
5.6.00.0080.02817.43
5.5.380.0020.03217.50
5.5.370.0100.03717.62
5.5.360.0000.03517.48
5.5.350.0050.03617.31
5.5.340.0060.02917.77
5.5.330.0040.02717.57
5.5.320.0030.02717.70
5.5.310.0070.03617.59
5.5.300.0060.02817.70
5.5.290.0080.03017.76
5.5.280.0050.03417.68
5.5.270.0040.02817.82
5.5.260.0020.03117.58
5.5.250.0030.02817.74
5.5.240.0070.02117.15
5.5.230.0100.02317.39
5.5.220.0100.03017.35
5.5.210.0050.02517.28
5.5.200.0090.02917.43
5.5.190.0040.03217.25
5.5.180.0030.03217.43
5.5.170.0080.00414.68
5.5.160.0070.02817.25
5.5.150.0080.03817.28
5.5.140.0030.03317.52
5.5.130.0050.03717.52
5.5.120.0020.03617.45
5.5.110.0060.03817.38
5.5.100.0030.02517.47
5.5.90.0070.02517.16
5.5.80.0120.02517.37
5.5.70.0120.03517.26
5.5.60.0060.02417.29
5.5.50.0050.02917.15
5.5.40.0100.02317.14
5.5.30.0050.03217.46
5.5.20.0080.04317.20
5.5.10.0070.02517.35
5.5.00.0070.03117.24
5.4.450.0020.02415.94
5.4.440.0090.02015.87
5.4.430.0050.02815.93
5.4.420.0030.03415.81
5.4.410.0110.03115.86
5.4.400.0030.02815.71
5.4.390.0030.04615.71
5.4.380.0060.03315.75
5.4.370.0050.02315.65
5.4.360.0080.02215.75
5.4.350.0080.03015.65
5.4.340.0090.02415.64
5.4.330.0040.00412.36
5.4.320.0090.03215.76
5.4.310.0050.02815.62
5.4.300.0080.02615.80
5.4.290.0060.02515.75
5.4.280.0040.02915.74
5.4.270.0060.02115.76
5.4.260.0050.04215.79
5.4.250.0070.02015.79
5.4.240.0130.02315.74
5.4.230.0050.03415.70
5.4.220.0100.02315.79
5.4.210.0050.02715.72
5.4.200.0080.02515.60
5.4.190.0030.02515.77
5.4.180.0000.03215.74
5.4.170.0030.02815.60
5.4.160.0050.02815.68
5.4.150.0100.02315.73
5.4.140.0070.02414.35
5.4.130.0080.02214.38
5.4.120.0070.02814.39
5.4.110.0090.03514.43
5.4.100.0040.03514.42
5.4.90.0040.03714.44
5.4.80.0070.02214.36
5.4.70.0020.03214.36
5.4.60.0020.02914.39
5.4.50.0020.02714.43
5.4.40.0060.02414.36
5.4.30.0050.02514.38
5.4.20.0060.02014.37
5.4.10.0070.02514.44
5.4.00.0070.02014.15
5.3.290.0020.02613.55
5.3.280.0050.03213.49
5.3.270.0050.03213.48
5.3.260.0050.02413.49
5.3.250.0060.02513.57
5.3.240.0050.02213.52
5.3.230.0020.04413.52
5.3.220.0070.02313.50
5.3.210.0020.03513.48
5.3.200.0030.02813.51
5.3.190.0130.02913.46
5.3.180.0020.04513.48
5.3.170.0030.02413.52
5.3.160.0020.02313.47
5.3.150.0000.02813.46
5.3.140.0050.03813.54
5.3.130.0050.02313.49
5.3.120.0020.03513.54
5.3.110.0030.02813.53
5.3.100.0050.03113.26
5.3.90.0050.02413.20
5.3.80.0030.02513.21
5.3.70.0050.02013.23
5.3.60.0080.02213.23
5.3.50.0070.02113.13
5.3.40.0030.04013.23
5.3.30.0030.02613.23
5.3.20.0070.02113.02
5.3.10.0060.01813.03
5.3.00.0030.02012.99

preferences:
41.68 ms | 401 KiB | 5 Q