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 ChangeAttr($name, $value) { foreach($this->attr as $try) { if ($try->Name() === $name) { $try->Value($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 { unset($attr[$name]); } } 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->ChangeAttr("href", "http://twitter.com"); $element3->AddAttr(new Attribute("src", "https://si0.twimg.com/profile_images/3439429669/c2c9d02095be44d026d358e0a39bced0_normal.jpeg")); $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.0170.00318.56
8.3.50.0080.00821.27
8.3.40.0120.00618.84
8.3.30.0100.00320.29
8.3.20.0050.00320.34
8.3.10.0050.00321.02
8.3.00.0040.00422.33
8.2.180.0120.00616.37
8.2.170.0140.00722.96
8.2.160.0130.00022.11
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0070.00026.16
8.2.120.0000.00820.86
8.2.110.0090.00019.52
8.2.100.0070.00718.16
8.2.90.0030.00517.88
8.2.80.0030.00517.97
8.2.70.0030.00517.36
8.2.60.0000.00817.50
8.2.50.0030.00518.04
8.2.40.0000.00818.05
8.2.30.0000.00719.39
8.2.20.0040.00417.81
8.2.10.0040.00417.68
8.2.00.0070.00017.76
8.1.280.0040.01125.92
8.1.270.0030.00623.99
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0000.01020.47
8.1.230.0040.00718.98
8.1.220.0050.00317.77
8.1.210.0090.00018.77
8.1.200.0070.00417.38
8.1.190.0040.00417.35
8.1.180.0040.00418.10
8.1.170.0050.00317.76
8.1.160.0040.00418.91
8.1.150.0000.00818.65
8.1.140.0070.00017.35
8.1.130.0030.00317.89
8.1.120.0000.00717.53
8.1.110.0040.00417.51
8.1.100.0040.00417.37
8.1.90.0000.00717.51
8.1.80.0040.00417.49
8.1.70.0050.00217.43
8.1.60.0030.00617.50
8.1.50.0000.00817.58
8.1.40.0040.00417.54
8.1.30.0000.00817.70
8.1.20.0080.00017.67
8.1.10.0040.00417.49
8.1.00.0000.00817.33
8.0.300.0040.00418.77
8.0.290.0030.00616.75
8.0.280.0000.00818.42
8.0.270.0030.00517.15
8.0.260.0060.00018.34
8.0.250.0030.00717.10
8.0.240.0040.00416.92
8.0.230.0030.00317.05
8.0.220.0000.00816.92
8.0.210.0030.00516.93
8.0.200.0000.00617.08
8.0.190.0000.00717.03
8.0.180.0050.00317.02
8.0.170.0040.00417.00
8.0.160.0030.00416.90
8.0.150.0080.00016.91
8.0.140.0060.00316.86
8.0.130.0030.00613.43
8.0.120.0000.00816.92
8.0.110.0000.00716.88
8.0.100.0050.00217.00
8.0.90.0040.00416.77
8.0.80.0100.00716.95
8.0.70.0040.00416.85
8.0.60.0020.00517.04
8.0.50.0060.00316.94
8.0.30.0090.00917.13
8.0.20.0100.00917.40
8.0.10.0030.00516.92
8.0.00.0120.00616.78
7.4.330.0030.00316.81
7.4.320.0030.00316.67
7.4.300.0000.00616.70
7.4.290.0030.00316.70
7.4.280.0030.00316.59
7.4.270.0000.00716.69
7.4.260.0030.00313.39
7.4.250.0030.00516.50
7.4.240.0040.00416.60
7.4.230.0070.00016.34
7.4.220.0060.01216.69
7.4.210.0060.01116.62
7.4.200.0030.00316.46
7.4.190.0030.00316.65
7.4.160.0130.01016.60
7.4.150.0130.00917.40
7.4.140.0130.00817.86
7.4.130.0070.01116.60
7.4.120.0070.01016.44
7.4.110.0150.00316.54
7.4.100.0070.01016.54
7.4.90.0070.01116.39
7.4.80.0170.00319.39
7.4.70.0160.00316.47
7.4.60.0120.01216.63
7.4.50.0040.00416.51
7.4.40.0100.00722.77
7.4.30.0060.01016.59
7.4.00.0000.01114.94
7.3.330.0060.00013.40
7.3.320.0030.00313.30
7.3.310.0000.00716.47
7.3.300.0070.00016.49
7.3.290.0120.00316.48
7.3.280.0100.00916.42
7.3.270.0060.01217.40
7.3.260.0060.01518.24
7.3.250.0110.00916.38
7.3.240.0030.01316.69
7.3.230.0060.01116.62
7.3.210.0100.00716.49
7.3.200.0140.01119.39
7.3.190.0120.00916.41
7.3.180.0090.00916.44
7.3.170.0160.00716.50
7.3.160.0000.01616.43
7.3.120.0100.00615.02
7.3.10.0080.00816.39
7.3.00.0030.00616.75
7.2.330.0090.00916.93
7.2.320.0080.01516.55
7.2.310.0060.01316.74
7.2.300.0130.01016.48
7.2.290.0130.00316.56
7.2.130.0070.01016.88
7.2.120.0040.01116.73
7.2.110.0090.00617.01
7.2.100.0030.01316.92
7.2.90.0040.01217.09
7.2.80.0060.00916.93
7.2.70.0090.00316.89
7.2.60.0090.00516.97
7.2.50.0000.01416.91
7.2.40.0070.00717.03
7.2.30.0060.01016.70
7.2.20.0090.00616.97
7.2.10.0080.00317.02
7.2.00.0090.00518.30
7.1.250.0070.01015.85
7.1.200.0070.00715.60
7.1.100.0060.00618.13
7.1.70.0080.00017.23
7.1.60.0030.00717.33
7.1.50.0080.00417.04
7.1.00.0030.07722.33
7.0.200.0080.00016.76
7.0.140.0100.06722.05
7.0.100.0070.04720.08
7.0.90.0200.04719.95
7.0.80.0000.08019.97
7.0.70.0070.05019.95
7.0.60.0230.08020.02
7.0.50.0130.06720.30
7.0.40.0100.08720.02
7.0.30.0130.07720.09
7.0.20.0130.08320.03
7.0.10.0070.07020.05
7.0.00.0200.06720.12
5.6.280.0000.07721.04
5.6.250.0130.06320.83
5.6.240.0100.04320.64
5.6.230.0130.04320.68
5.6.220.0130.03720.54
5.6.210.0000.07720.67
5.6.200.0070.08021.06
5.6.190.0070.07721.17
5.6.180.0070.06721.06
5.6.170.0130.07720.97
5.6.160.0100.06321.00
5.6.150.0030.06721.17
5.6.140.0030.06020.97
5.6.130.0030.05021.20
5.6.120.0030.09720.96
5.6.110.0100.07321.07
5.6.100.0030.07021.09
5.6.90.0100.08320.94
5.6.80.0100.07720.47
5.6.70.0030.06720.50
5.6.60.0170.03720.43
5.6.50.0100.08020.44
5.6.40.0100.07320.52
5.6.30.0130.07320.43
5.6.20.0100.04320.48
5.6.10.0130.07320.52
5.6.00.0100.04720.39
5.5.380.0130.07720.46
5.5.370.0170.07720.46
5.5.360.0100.07720.36
5.5.350.0070.07020.42
5.5.340.0130.07720.90
5.5.330.0200.06320.96
5.5.320.0200.04320.77
5.5.310.0000.05020.95
5.5.300.0070.07720.91
5.5.290.0030.04320.86
5.5.280.0030.05320.80
5.5.270.0100.08320.82
5.5.260.0100.08720.95
5.5.250.0000.07020.74
5.5.240.0030.04020.20
5.5.230.0130.07320.34
5.5.220.0200.05320.30
5.5.210.0070.08020.14
5.5.200.0030.07720.15
5.5.190.0070.04720.14
5.5.180.0130.07020.12
5.5.160.0130.07720.03
5.5.150.0100.04320.19
5.5.140.0070.06020.30
5.5.130.0100.08020.18
5.5.120.0170.03720.25
5.5.110.0170.05720.20
5.5.100.0170.06320.20
5.5.90.0130.07020.18
5.5.80.0130.06020.10
5.5.70.0100.07320.11
5.5.60.0000.07020.18
5.5.50.0070.03720.09
5.5.40.0200.06020.11
5.5.30.0000.07020.11
5.5.20.0130.07320.14
5.5.10.0070.05320.07
5.5.00.0030.07320.13
5.4.450.0100.07319.48
5.4.440.0100.08019.23
5.4.430.0070.06019.57
5.4.420.0230.06019.45
5.4.410.0130.07319.22
5.4.400.0030.07018.88
5.4.390.0000.04719.12
5.4.380.0000.06719.23
5.4.370.0070.07319.16
5.4.360.0170.07319.03
5.4.350.0030.08019.05
5.4.340.0030.07018.91
5.4.320.0100.04319.09
5.4.310.0100.06019.21
5.4.300.0030.07719.13
5.4.290.0000.07318.88
5.4.280.0100.06719.25
5.4.270.0000.08319.02
5.4.260.0170.06719.02
5.4.250.0070.07019.11
5.4.240.0100.07019.22
5.4.230.0170.06719.02
5.4.220.0030.07018.90
5.4.210.0070.08719.02
5.4.200.0030.07318.87
5.4.190.0070.06018.87
5.4.180.0070.07719.04
5.4.170.0100.07318.87
5.4.160.0100.07319.07
5.4.150.0100.05019.16
5.4.140.0100.06316.40
5.4.130.0200.06016.30
5.4.120.0100.05016.33
5.4.110.0030.07716.55
5.4.100.0070.05016.54
5.4.90.0000.05316.45
5.4.80.0030.07016.36
5.4.70.0100.05716.46
5.4.60.0070.07316.42
5.4.50.0030.07716.51
5.4.40.0130.04716.51
5.4.30.0070.03316.53
5.4.20.0070.07716.41
5.4.10.0030.05716.51
5.4.00.0100.07315.84
5.3.290.0000.04314.65
5.3.280.0000.09014.67
5.3.270.0030.09014.80
5.3.260.0270.05014.71
5.3.250.0030.08014.64
5.3.240.0100.07714.80
5.3.230.0070.06014.77
5.3.220.0130.04014.76
5.3.210.0070.05314.68
5.3.200.0100.03314.59
5.3.190.0070.03714.69
5.3.180.0030.03714.65
5.3.170.0070.05314.57
5.3.160.0130.07014.60
5.3.150.0070.07314.60
5.3.140.0100.06314.67
5.3.130.0070.04314.63
5.3.120.0100.07014.62
5.3.110.0100.07314.56
5.3.100.0070.07314.14
5.3.90.0030.07014.09
5.3.80.0070.04714.18
5.3.70.0030.07013.96
5.3.60.0070.06014.08
5.3.50.0070.06313.91
5.3.40.0030.07713.91
5.3.30.0200.06314.07
5.3.20.0030.06713.78
5.3.10.0070.03713.69
5.3.00.0070.06713.70

preferences:
51.65 ms | 401 KiB | 5 Q