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])-1); } var_dump($as); array_push($newlist, new Attribute($as[0], $as[1])); } 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.0110.00718.38
8.3.50.0100.01021.99
8.3.40.0150.00418.71
8.3.30.0040.01118.57
8.3.20.0040.00418.60
8.3.10.0080.00020.53
8.3.00.0060.00617.50
8.2.180.0120.00316.63
8.2.170.0090.00622.96
8.2.160.0100.00622.27
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0060.00326.16
8.2.120.0060.00319.70
8.2.110.0090.00321.03
8.2.100.0000.01117.91
8.2.90.0050.00319.17
8.2.80.0000.00817.97
8.2.70.0040.00417.63
8.2.60.0000.00818.05
8.2.50.0000.00918.07
8.2.40.0050.00318.16
8.2.30.0070.00019.72
8.2.20.0030.00617.66
8.2.10.0000.00917.66
8.2.00.0050.00317.76
8.1.280.0090.01225.92
8.1.270.0040.00423.99
8.1.260.0030.00626.35
8.1.250.0060.00328.09
8.1.240.0130.00020.70
8.1.230.0040.00821.06
8.1.220.0040.00418.77
8.1.210.0000.00818.98
8.1.200.0030.00617.38
8.1.190.0000.00817.29
8.1.180.0080.00018.10
8.1.170.0000.00918.87
8.1.160.0040.00418.96
8.1.150.0070.00018.61
8.1.140.0040.00417.53
8.1.130.0030.00317.90
8.1.120.0000.00717.47
8.1.110.0030.00517.39
8.1.100.0040.00417.39
8.1.90.0080.00017.44
8.1.80.0000.00717.51
8.1.70.0000.00817.38
8.1.60.0050.00317.62
8.1.50.0030.00617.52
8.1.40.0030.00617.45
8.1.30.0000.00817.59
8.1.20.0050.00317.69
8.1.10.0000.00817.38
8.1.00.0050.00217.40
8.0.300.0000.01019.95
8.0.290.0050.00216.88
8.0.280.0030.00318.46
8.0.270.0000.00717.34
8.0.260.0070.00016.94
8.0.250.0040.00416.96
8.0.240.0060.00617.01
8.0.230.0060.00317.10
8.0.220.0000.00716.88
8.0.210.0080.00016.96
8.0.200.0000.00717.02
8.0.190.0000.00816.93
8.0.180.0030.00517.04
8.0.170.0000.00816.92
8.0.160.0030.00317.07
8.0.150.0000.00816.86
8.0.140.0030.00616.98
8.0.130.0000.00713.38
8.0.120.0040.00416.99
8.0.110.0000.00817.00
8.0.100.0000.00716.83
8.0.90.0040.00416.93
8.0.80.0040.01216.98
8.0.70.0030.00516.88
8.0.60.0030.00516.86
8.0.50.0040.00416.87
8.0.30.0070.01217.09
8.0.20.0170.00217.40
8.0.10.0000.00817.00
8.0.00.0090.01116.75
7.4.330.0000.00514.84
7.4.320.0030.00316.65
7.4.300.0000.00716.68
7.4.290.0040.00416.73
7.4.280.0030.00616.48
7.4.270.0030.00316.61
7.4.260.0060.00013.42
7.4.250.0040.00416.69
7.4.240.0030.00516.61
7.4.230.0050.00216.67
7.4.220.0090.01516.70
7.4.210.0100.00716.59
7.4.200.0040.00416.52
7.4.190.0030.00516.83
7.4.160.0150.00816.54
7.4.150.0160.00317.40
7.4.140.0070.01117.86
7.4.130.0140.00716.49
7.4.120.0070.01116.63
7.4.110.0090.01216.80
7.4.100.0110.00616.52
7.4.90.0060.01216.62
7.4.80.0090.00919.04
7.4.70.0030.01416.58
7.4.60.0060.01016.66
7.4.50.0040.00416.48
7.4.40.0150.00322.27
7.4.30.0100.00716.59
7.4.00.0030.01315.16
7.3.330.0000.00513.43
7.3.320.0050.00013.35
7.3.310.0000.00716.27
7.3.300.0040.00416.40
7.3.290.0070.00716.42
7.3.280.0070.01016.46
7.3.270.0160.01017.40
7.3.260.0070.01118.24
7.3.250.0140.00516.57
7.3.240.0080.00916.55
7.3.230.0140.00316.61
7.3.210.0110.00816.46
7.3.200.0070.01019.39
7.3.190.0090.01216.73
7.3.180.0050.01116.55
7.3.170.0090.00916.68
7.3.160.0050.01216.64
7.3.120.0080.00315.17
7.3.10.0140.00316.26
7.3.00.0060.00616.49
7.2.330.0060.01216.57
7.2.320.0030.01416.88
7.2.310.0000.02116.80
7.2.300.0200.00316.53
7.2.290.0100.00716.86
7.2.130.0100.00716.64
7.2.120.0040.01116.64
7.2.110.0030.01016.79
7.2.100.0150.00416.86
7.2.90.0060.00616.64
7.2.80.0100.01416.77
7.2.70.0070.01016.81
7.2.60.0110.00516.92
7.2.50.0090.01716.86
7.2.40.0190.00616.95
7.2.30.0140.01016.61
7.2.20.0110.01517.09
7.2.10.0100.01416.86
7.2.00.0140.00818.17
7.1.250.0130.00315.73
7.1.100.0040.01118.29
7.1.70.0030.00717.13
7.1.60.0060.01919.40
7.1.50.0000.01516.74
7.1.00.0030.07322.44
7.0.200.0050.00516.77
7.0.140.0000.07322.00
7.0.100.0100.07720.08
7.0.90.0170.07319.97
7.0.80.0070.08019.98
7.0.70.0100.07319.95
7.0.60.0100.07019.95
7.0.50.0130.07320.32
7.0.40.0100.08320.11
7.0.30.0070.05020.10
7.0.20.0030.08020.03
7.0.10.0200.06320.17
7.0.00.0100.08320.03
5.6.280.0130.06721.14
5.6.250.0030.08320.73
5.6.240.0070.07320.80
5.6.230.0200.07720.55
5.6.220.0070.05720.60
5.6.210.0070.04720.52
5.6.200.0100.08721.10
5.6.190.0170.05321.00
5.6.180.0170.07721.19
5.6.170.0200.07321.16
5.6.160.0170.07721.16
5.6.150.0030.08721.11
5.6.140.0200.07320.98
5.6.130.0100.08021.08
5.6.120.0030.06321.09
5.6.110.0070.08721.05
5.6.100.0100.07721.08
5.6.90.0030.08321.04
5.6.80.0070.07320.45
5.6.70.0070.06720.59
5.6.60.0070.08020.45
5.6.50.0000.08720.44
5.6.40.0100.04020.54
5.6.30.0070.03720.40
5.6.20.0130.03320.45
5.6.10.0070.04320.34
5.6.00.0000.04320.50
5.5.380.0100.08020.40
5.5.370.0100.08020.47
5.5.360.0200.06020.54
5.5.350.0070.08020.44
5.5.340.0070.09020.97
5.5.330.0030.06320.86
5.5.320.0200.07020.81
5.5.310.0100.08020.84
5.5.300.0070.07720.97
5.5.290.0000.05720.66
5.5.280.0130.06020.96
5.5.270.0100.07320.87
5.5.260.0100.08020.80
5.5.250.0170.04020.69
5.5.240.0070.04720.23
5.5.230.0130.06720.31
5.5.220.0170.06320.25
5.5.210.0030.08320.31
5.5.200.0100.07320.21
5.5.190.0070.03720.31
5.5.180.0070.03720.27
5.5.160.0070.03720.35
5.5.150.0070.03720.32
5.5.140.0000.04320.20
5.5.130.0030.03720.27
5.5.120.0070.03720.25
5.5.110.0030.04020.15
5.5.100.0030.04020.13
5.5.90.0030.04020.09
5.5.80.0100.03320.12
5.5.70.0070.03720.16
5.5.60.0000.04720.11
5.5.50.0100.06320.12
5.5.40.0070.03720.11
5.5.30.0070.03720.20
5.5.20.0030.06020.18
5.5.10.0100.03320.09
5.5.00.0030.04020.09
5.4.450.0000.05319.51
5.4.440.0130.07319.20
5.4.430.0030.08319.24
5.4.420.0030.05019.27
5.4.410.0170.07019.43
5.4.400.0070.08018.88
5.4.390.0030.04719.14
5.4.380.0000.05018.95
5.4.370.0070.07719.13
5.4.360.0070.07319.12
5.4.350.0000.04319.23
5.4.340.0070.04019.17
5.4.320.0070.04019.03
5.4.310.0000.04018.88
5.4.300.0030.03719.12
5.4.290.0030.03719.04
5.4.280.0030.03718.90
5.4.270.0030.03718.87
5.4.260.0130.02719.14
5.4.250.0030.03719.16
5.4.240.0030.03719.13
5.4.230.0000.03719.10
5.4.220.0030.04019.12
5.4.210.0030.06319.20
5.4.200.0000.04019.13
5.4.190.0030.03719.08
5.4.180.0070.03719.08
5.4.170.0030.03719.02
5.4.160.0000.04018.88
5.4.150.0030.03319.01
5.4.140.0070.03716.48
5.4.130.0000.03716.48
5.4.120.0070.05716.45
5.4.110.0000.04016.40
5.4.100.0000.05016.49
5.4.90.0000.03716.39
5.4.80.0000.03716.50
5.4.70.0000.03716.43
5.4.60.0070.03716.52
5.4.50.0030.03316.50
5.4.40.0030.03316.46
5.4.30.0070.03316.45
5.4.20.0000.04016.41
5.4.10.0000.05016.30
5.4.00.0000.03315.96
5.3.290.0030.03714.77
5.3.280.0000.04714.64
5.3.270.0100.04014.81
5.3.260.0000.03714.72
5.3.250.0000.04314.64
5.3.240.0100.05014.72
5.3.230.0030.03714.78
5.3.220.0000.04014.65
5.3.210.0030.04314.65
5.3.200.0000.03714.69
5.3.190.0000.04314.62
5.3.180.0000.04014.68
5.3.170.0000.03714.74
5.3.160.0000.03714.69
5.3.150.0070.03314.71
5.3.140.0030.05014.61
5.3.130.0070.05014.72
5.3.120.0000.04014.55
5.3.110.0070.05014.68
5.3.100.0030.05014.03
5.3.90.0000.04014.05
5.3.80.0030.07314.19
5.3.70.0030.07314.18
5.3.60.0130.07313.95
5.3.50.0100.07014.13
5.3.40.0100.07313.99
5.3.30.0070.04713.88
5.3.20.0100.06713.69
5.3.10.0070.03313.64
5.3.00.0100.03313.72

preferences:
42.76 ms | 401 KiB | 5 Q