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.0.0rc20.0050.01316.91
8.0.0rc10.0030.01616.79
8.0.0beta30.0100.00916.74
8.0.0beta10.0120.00616.74
8.0.0alpha30.0100.00716.69
8.0.0alpha20.0130.00616.82
8.0.0alpha10.0090.00916.59
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.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