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); } 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.0000.01418.43
8.3.50.0140.00921.92
8.3.40.0000.01518.68
8.3.30.0080.00818.76
8.3.20.0080.00018.72
8.3.10.0040.00420.71
8.3.00.0000.00821.77
8.2.180.0110.00418.29
8.2.170.0110.00322.96
8.2.160.0070.00722.25
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0030.00619.20
8.2.110.0090.00020.52
8.2.100.0090.00317.84
8.2.90.0040.00419.30
8.2.80.0030.00617.97
8.2.70.0000.00917.63
8.2.60.0090.00018.05
8.2.50.0000.00818.07
8.2.40.0060.00318.05
8.2.30.0080.00021.22
8.2.20.0030.00617.75
8.2.10.0000.00817.75
8.2.00.0100.00017.76
8.1.280.0110.01125.92
8.1.270.0070.00422.30
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0060.00322.12
8.1.230.0090.00322.32
8.1.220.0000.00918.77
8.1.210.0060.00319.05
8.1.200.0040.00417.35
8.1.190.0000.00919.07
8.1.180.0040.00418.10
8.1.170.0000.00918.84
8.1.160.0000.00818.91
8.1.150.0030.00518.54
8.1.140.0000.00717.47
8.1.130.0030.00317.77
8.1.120.0030.00617.35
8.1.110.0040.00417.44
8.1.100.0050.00317.37
8.1.90.0040.00417.51
8.1.80.0000.00717.41
8.1.70.0070.00017.39
8.1.60.0050.00317.63
8.1.50.0000.00817.43
8.1.40.0000.00817.44
8.1.30.0040.00417.51
8.1.20.0000.00917.72
8.1.10.0060.00317.45
8.1.00.0080.00417.30
8.0.300.0070.00019.97
8.0.290.0070.00017.05
8.0.280.0000.00718.39
8.0.270.0000.00816.90
8.0.260.0070.00016.90
8.0.250.0030.00617.06
8.0.240.0040.00416.95
8.0.230.0040.00417.11
8.0.220.0000.00716.89
8.0.210.0000.00816.92
8.0.200.0030.00317.05
8.0.190.0000.00817.01
8.0.180.0040.00416.94
8.0.170.0040.00416.96
8.0.160.0080.00017.03
8.0.150.0030.00516.95
8.0.140.0000.00716.88
8.0.130.0030.00313.46
8.0.120.0040.00416.86
8.0.110.0000.00816.92
8.0.100.0070.00016.87
8.0.90.0000.00716.79
8.0.80.0070.00717.03
8.0.70.0030.00616.99
8.0.60.0070.00016.79
8.0.50.0040.00416.99
8.0.30.0060.01717.21
8.0.20.0110.00817.40
8.0.10.0000.00817.14
8.0.00.0100.00716.86
7.4.330.0000.00516.67
7.4.320.0000.00616.53
7.4.300.0000.00616.63
7.4.290.0000.00716.45
7.4.280.0030.00616.48
7.4.270.0030.00516.54
7.4.260.0000.00513.37
7.4.250.0080.00016.64
7.4.240.0000.00716.68
7.4.230.0000.00816.64
7.4.220.0150.00916.67
7.4.210.0100.00716.69
7.4.200.0000.00716.57
7.4.190.0000.00716.55
7.4.160.0100.00616.63
7.4.150.0100.00617.40
7.4.140.0090.01017.86
7.4.130.0080.00916.52
7.4.120.0070.01216.50
7.4.110.0000.01716.52
7.4.100.0110.01116.68
7.4.90.0060.01216.63
7.4.80.0110.00719.39
7.4.70.0120.00616.32
7.4.60.0060.01116.62
7.4.50.0060.00316.48
7.4.40.0040.01522.77
7.4.30.0080.00816.74
7.4.00.0120.00415.15
7.3.330.0030.00313.21
7.3.320.0000.01313.41
7.3.310.0050.00316.27
7.3.300.0040.00416.49
7.3.290.0030.01216.47
7.3.280.0080.01016.44
7.3.270.0030.01417.40
7.3.260.0090.01318.24
7.3.250.0150.00316.66
7.3.240.0100.00716.76
7.3.230.0100.00716.53
7.3.210.0090.01216.69
7.3.200.0070.01119.39
7.3.190.0110.00916.47
7.3.180.0060.01016.50
7.3.170.0130.00316.48
7.3.160.0050.01016.52
7.3.120.0000.01714.67
7.2.330.0150.00316.93
7.2.320.0090.01216.88
7.2.310.0000.01716.87
7.2.300.0060.01016.91
7.2.290.0100.00716.74
7.2.00.0040.01419.54
7.1.100.0040.00718.24
7.1.70.0000.00716.95
7.1.60.0170.00719.40
7.1.50.0140.00716.98
7.1.00.0000.06722.31
7.0.200.0200.00616.59
7.0.140.0000.07722.01
7.0.100.0030.04019.99
7.0.90.0130.04319.95
7.0.80.0030.03720.01
7.0.70.0070.03319.93
7.0.60.0030.04020.05
7.0.50.0030.04320.39
7.0.40.0030.04320.11
7.0.30.0030.03320.14
7.0.20.0030.04020.10
7.0.10.0030.04020.09
7.0.00.0100.03020.04
5.6.280.0000.07720.86
5.6.250.0070.04020.62
5.6.240.0070.04020.62
5.6.230.0070.03720.55
5.6.220.0100.03320.72
5.6.210.0070.03720.47
5.6.200.0070.03321.13
5.6.190.0070.03321.13
5.6.180.0100.04021.09
5.6.170.0100.03721.15
5.6.160.0000.03721.18
5.6.150.0030.03321.09
5.6.140.0130.03321.09
5.6.130.0070.03321.05
5.6.120.0070.04321.10
5.6.110.0100.06021.08
5.6.100.0100.06321.12
5.6.90.0070.08321.10
5.6.80.0030.08720.45
5.6.70.0030.05320.37
5.6.60.0100.03320.59
5.6.50.0100.04320.60
5.6.40.0000.04320.32
5.6.30.0130.06020.47
5.6.20.0100.07320.44
5.6.10.0030.06720.46
5.6.00.0030.04020.47
5.5.380.0070.03720.42
5.5.370.0030.04020.44
5.5.360.0070.03020.49
5.5.350.0030.04020.41
5.5.340.0030.04320.82
5.5.330.0030.04020.86
5.5.320.0070.03020.95
5.5.310.0030.04020.81
5.5.300.0070.03020.93
5.5.290.0100.02720.84
5.5.280.0030.04320.95
5.5.270.0030.08320.77
5.5.260.0100.08320.81
5.5.250.0100.08020.75
5.5.240.0100.03320.07
5.5.230.0000.06320.20
5.5.220.0100.03320.25
5.5.210.0030.03720.23
5.5.200.0170.06720.27
5.5.190.0170.03020.20
5.5.180.0000.05020.27
5.5.160.0100.04720.13
5.5.150.0130.07020.32
5.5.140.0030.05720.22
5.5.130.0130.07720.31
5.5.120.0100.06720.19
5.5.110.0000.04320.32
5.5.100.0070.07320.21
5.5.90.0000.04320.14
5.5.80.0070.04020.20
5.5.70.0070.03720.08
5.5.60.0070.03320.07
5.5.50.0130.02719.98
5.5.40.0130.07020.09
5.5.30.0030.04020.07
5.5.20.0070.07720.13
5.5.10.0100.07320.09
5.5.00.0070.03720.11
5.4.450.0100.03719.45
5.4.440.0000.04319.44
5.4.430.0070.06319.41
5.4.420.0000.03719.35
5.4.410.0100.07719.10
5.4.400.0070.05319.14
5.4.390.0030.07019.13
5.4.380.0100.07718.92
5.4.370.0070.04719.23
5.4.360.0100.07019.23
5.4.350.0100.05719.13
5.4.340.0030.03719.13
5.4.320.0070.05019.04
5.4.310.0070.03719.04
5.4.300.0130.06719.04
5.4.290.0100.04719.09
5.4.280.0030.04019.13
5.4.270.0030.07319.08
5.4.260.0070.08019.04
5.4.250.0100.03319.20
5.4.240.0070.03318.87
5.4.230.0070.07318.89
5.4.220.0100.07319.03
5.4.210.0070.03319.02
5.4.200.0070.03319.15
5.4.190.0100.06718.95
5.4.180.0100.07719.13
5.4.170.0030.08019.02
5.4.160.0070.07019.00
5.4.150.0030.04719.11
5.4.140.0000.04316.45
5.4.130.0130.05016.42
5.4.120.0030.06716.49
5.4.110.0070.04016.48
5.4.100.0030.04016.40
5.4.90.0030.05316.48
5.4.80.0030.05316.50
5.4.70.0170.05316.53
5.4.60.0030.07316.38
5.4.50.0030.07316.35
5.4.40.0030.03716.46
5.4.30.0030.07316.37
5.4.20.0070.07016.41
5.4.10.0100.07016.53
5.4.00.0070.07015.94
5.3.290.0030.04014.69
5.3.280.0030.07714.58
5.3.270.0070.03314.65
5.3.260.0030.07714.68
5.3.250.0100.07714.61
5.3.240.0100.06714.61
5.3.230.0070.03314.61
5.3.220.0070.06314.69
5.3.210.0030.06014.62
5.3.200.0100.06314.73
5.3.190.0030.04014.76
5.3.180.0030.06714.76
5.3.170.0100.07314.63
5.3.160.0030.08314.65
5.3.150.0100.05014.59
5.3.140.0030.07014.55
5.3.130.0100.04314.54
5.3.120.0070.07714.68
5.3.110.0070.05714.64
5.3.100.0000.04314.05
5.3.90.0030.07014.00
5.3.80.0070.07314.00
5.3.70.0030.05314.13
5.3.60.0030.06714.04
5.3.50.0070.07013.90
5.3.40.0030.03714.13
5.3.30.0030.04014.06
5.3.20.0000.04013.89
5.3.10.0100.07713.61
5.3.00.0030.06713.84

preferences:
51.73 ms | 401 KiB | 5 Q