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) { $this->attr = 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); } array_push($newlist, new Attribute($as[0], $as[1])); } $this->attr = 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.60.0090.00618.68
8.3.50.0110.01121.08
8.3.40.0070.01018.59
8.3.30.0040.01118.76
8.3.20.0030.00618.60
8.3.10.0040.00419.25
8.3.00.0080.00023.61
8.2.180.0140.00418.17
8.2.170.0110.00422.96
8.2.160.0120.00320.48
8.2.150.0050.00324.18
8.2.140.0060.00324.66
8.2.130.0030.00526.16
8.2.120.0060.00321.12
8.2.110.0030.00620.94
8.2.100.0060.00617.81
8.2.90.0000.00819.41
8.2.80.0080.00017.97
8.2.70.0000.00917.75
8.2.60.0080.00018.16
8.2.50.0040.00418.10
8.2.40.0030.00618.00
8.2.30.0040.00419.77
8.2.20.0050.00317.75
8.2.10.0090.00017.77
8.2.00.0010.00917.77
8.1.280.0140.00025.92
8.1.270.0080.00023.99
8.1.260.0090.00626.35
8.1.250.0040.00428.09
8.1.240.0100.00023.98
8.1.230.0090.00620.43
8.1.220.0040.00417.77
8.1.210.0040.00418.77
8.1.200.0040.00417.35
8.1.190.0080.00017.36
8.1.180.0050.00318.10
8.1.170.0060.00318.73
8.1.160.0000.00818.95
8.1.150.0030.00618.71
8.1.140.0030.00517.39
8.1.130.0000.00717.73
8.1.120.0000.00717.54
8.1.110.0030.00517.46
8.1.100.0040.00417.43
8.1.90.0050.00217.41
8.1.80.0000.00717.48
8.1.70.0040.00417.37
8.1.60.0000.00917.57
8.1.50.0050.00317.46
8.1.40.0030.00517.60
8.1.30.0030.00517.65
8.1.20.0030.00517.69
8.1.10.0030.00517.51
8.1.00.0040.00417.43
8.0.300.0040.00418.77
8.0.290.0020.00516.88
8.0.280.0050.00318.39
8.0.270.0030.00717.29
8.0.260.0040.00416.90
8.0.250.0040.00417.04
8.0.240.0000.00817.10
8.0.230.0030.00517.05
8.0.220.0030.00316.93
8.0.210.0050.00317.02
8.0.200.0030.00316.96
8.0.190.0050.00216.99
8.0.180.0030.00617.04
8.0.170.0000.00916.96
8.0.160.0000.00717.07
8.0.150.0100.00016.84
8.0.140.0060.00316.92
8.0.130.0000.00613.39
8.0.120.0080.00016.86
8.0.110.0000.00816.99
8.0.100.0040.00417.02
8.0.90.0040.00417.03
8.0.80.0080.00816.99
8.0.70.0020.00516.88
8.0.60.0000.00716.82
8.0.50.0040.00417.02
8.0.30.0160.00717.03
8.0.20.0100.00917.40
8.0.10.0030.00517.02
8.0.00.0070.01016.80
7.4.330.0050.00014.66
7.4.320.0030.00316.74
7.4.300.0030.00316.68
7.4.290.0000.00716.58
7.4.280.0030.00616.67
7.4.270.0070.00016.70
7.4.260.0050.00013.38
7.4.250.0050.00516.57
7.4.240.0070.00016.70
7.4.230.0000.00716.52
7.4.220.0070.01116.63
7.4.210.0050.01316.62
7.4.200.0040.00416.64
7.4.190.0070.00016.55
7.4.160.0160.00616.61
7.4.150.0100.00717.40
7.4.140.0080.01017.86
7.4.130.0090.00916.61
7.4.120.0120.00516.62
7.4.110.0100.01016.75
7.4.100.0110.00616.60
7.4.90.0090.00916.79
7.4.80.0150.00619.37
7.4.70.0070.01416.54
7.4.60.0070.01016.59
7.4.50.0040.00416.21
7.4.40.0040.01522.52
7.4.30.0110.00616.71
7.4.00.0070.01014.87
7.3.330.0030.00313.59
7.3.320.0000.00513.38
7.3.310.0000.00716.41
7.3.300.0000.00816.38
7.3.290.0080.00616.50
7.3.280.0110.00516.46
7.3.270.0090.00917.40
7.3.260.0130.00818.24
7.3.250.0110.00616.53
7.3.240.0120.01216.37
7.3.230.0030.01516.70
7.3.210.0060.01216.36
7.3.200.0090.00919.39
7.3.190.0090.00616.55
7.3.180.0170.00416.63
7.3.170.0070.01016.46
7.3.160.0070.00716.54
7.3.120.0040.01015.22
7.3.10.0100.01016.56
7.3.00.0220.00416.11
7.2.330.0030.01516.84
7.2.320.0180.00616.75
7.2.310.0100.01316.77
7.2.300.0140.00716.65
7.2.290.0140.00716.77
7.2.130.0150.01216.57
7.2.120.0190.00916.73
7.2.110.0400.00316.63
7.2.100.0240.01116.88
7.2.90.0100.00716.53
7.2.80.0140.00916.65
7.2.70.0210.00916.56
7.2.60.0150.00316.54
7.2.50.0320.00616.69
7.2.40.0150.01217.03
7.2.30.0230.00517.00
7.2.20.0070.01116.75
7.2.10.0090.00917.04
7.2.00.0050.01016.59
7.1.250.0190.00615.45
7.1.100.0080.00417.97
7.1.70.0030.00717.29
7.1.60.0100.01319.40
7.1.50.0040.00717.07
7.1.00.0000.07722.43
7.0.200.0040.00416.97
7.0.140.0000.07722.16
7.0.100.0100.05319.99
7.0.90.0130.07719.92
7.0.80.0400.07719.91
7.0.70.0200.07319.92
7.0.60.0030.07020.07
7.0.50.0170.03720.39
7.0.40.0100.08020.18
7.0.30.0100.09320.19
7.0.20.0000.08720.04
7.0.10.0000.05020.14
7.0.00.0170.04720.05
5.6.280.0030.07320.86
5.6.250.0100.08320.54
5.6.240.0100.04320.66
5.6.230.0100.08020.63
5.6.220.0070.08020.58
5.6.210.0070.07720.75
5.6.200.0100.08321.18
5.6.190.0030.08020.98
5.6.180.0030.08721.00
5.6.170.0070.08721.16
5.6.160.0130.06021.16
5.6.150.0070.05021.22
5.6.140.0170.07721.09
5.6.130.0070.05021.03
5.6.120.0100.06320.99
5.6.110.0200.07321.07
5.6.100.0070.07021.02
5.6.90.0200.03721.02
5.6.80.0170.07320.31
5.6.70.0100.03720.48
5.6.60.0100.04020.42
5.6.50.0100.07720.39
5.6.40.0000.08320.57
5.6.30.0200.07320.36
5.6.20.0070.06020.48
5.6.10.0170.07320.50
5.6.00.0070.08020.43
5.5.380.0070.07720.32
5.5.370.0100.08320.37
5.5.360.0130.07320.34
5.5.350.0100.08320.42
5.5.340.0130.07020.82
5.5.330.0130.08020.98
5.5.320.0100.08720.98
5.5.310.0070.08720.97
5.5.300.0100.08320.78
5.5.290.0070.08020.96
5.5.280.0070.09020.82
5.5.270.0070.05020.87
5.5.260.0070.08720.77
5.5.250.0000.05020.78
5.5.240.0030.07020.36
5.5.230.0130.07720.34
5.5.220.0070.07320.32
5.5.210.0070.08020.31
5.5.200.0030.08320.18
5.5.190.0100.08720.04
5.5.180.0100.06720.19
5.5.160.0130.06720.22
5.5.150.0100.07320.19
5.5.140.0170.06020.27
5.5.130.0130.07320.26
5.5.120.0000.05320.14
5.5.110.0170.04720.26
5.5.100.0200.06720.03
5.5.90.0100.07320.18
5.5.80.0170.07020.02
5.5.70.0130.03720.15
5.5.60.0130.06719.95
5.5.50.0100.07320.04
5.5.40.0130.05320.04
5.5.30.0070.08320.19
5.5.20.0200.07019.97
5.5.10.0100.07720.01
5.5.00.0070.05320.07
5.4.450.0000.05319.56
5.4.440.0070.07319.46
5.4.430.0070.08019.50
5.4.420.0030.07719.27
5.4.410.0130.07719.14
5.4.400.0130.06018.90
5.4.390.0130.04719.12
5.4.380.0130.07019.21
5.4.370.0070.07019.16
5.4.360.0100.06719.12
5.4.350.0130.07318.93
5.4.340.0100.05719.19
5.4.320.0030.07719.03
5.4.310.0100.04019.21
5.4.300.0070.06719.12
5.4.290.0070.05719.12
5.4.280.0070.08019.05
5.4.270.0130.06019.09
5.4.260.0130.06018.94
5.4.250.0070.08319.12
5.4.240.0070.04019.20
5.4.230.0100.06319.22
5.4.220.0070.07719.11
5.4.210.0100.04019.17
5.4.200.0100.04718.86
5.4.190.0070.06719.20
5.4.180.0000.08719.20
5.4.170.0070.07718.89
5.4.160.0030.04719.21
5.4.150.0070.06719.01
5.4.140.0100.03316.50
5.4.130.0130.02716.36
5.4.120.0100.04016.50
5.4.110.0070.07716.56
5.4.100.0030.05716.52
5.4.90.0000.04716.39
5.4.80.0100.06316.51
5.4.70.0070.05316.36
5.4.60.0000.05016.52
5.4.50.0100.06716.50
5.4.40.0070.06716.34
5.4.30.0070.07016.43
5.4.20.0070.07016.49
5.4.10.0000.08016.49
5.4.00.0170.03715.70
5.3.290.0070.06714.85
5.3.280.0070.08014.79
5.3.270.0030.08014.59
5.3.260.0070.07314.74
5.3.250.0000.08014.63
5.3.240.0000.05014.79
5.3.230.0030.04014.66
5.3.220.0030.06014.74
5.3.210.0000.05714.70
5.3.200.0100.07714.78
5.3.190.0070.07314.68
5.3.180.0100.07314.65
5.3.170.0100.06314.70
5.3.160.0000.05314.65
5.3.150.0130.04014.64
5.3.140.0030.07014.71
5.3.130.0030.08014.60
5.3.120.0100.06314.57
5.3.110.0070.07714.68
5.3.100.0070.04714.02
5.3.90.0100.05314.13
5.3.80.0100.03714.23
5.3.70.0130.07313.97
5.3.60.0030.06314.20
5.3.50.0070.07713.90
5.3.40.0030.04713.91
5.3.30.0100.05314.03
5.3.20.0000.06013.76
5.3.10.0100.04013.78
5.3.00.0100.06313.68

preferences:
33.37 ms | 401 KiB | 5 Q