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])-2); } 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.0060.00916.73
8.3.50.0110.00922.12
8.3.40.0070.00718.77
8.3.30.0110.00418.96
8.3.20.0070.00020.25
8.3.10.0080.00023.39
8.3.00.0050.00320.58
8.2.180.0130.00616.88
8.2.170.0160.00322.96
8.2.160.0000.01522.26
8.2.150.0080.00024.18
8.2.140.0030.00624.66
8.2.130.0040.00426.16
8.2.120.0080.00022.12
8.2.110.0030.00719.52
8.2.100.0090.00317.97
8.2.90.0080.00019.17
8.2.80.0000.00917.97
8.2.70.0090.00017.75
8.2.60.0050.00318.05
8.2.50.0000.00918.07
8.2.40.0030.00519.46
8.2.30.0040.00418.03
8.2.20.0030.00517.76
8.2.10.0040.00417.71
8.2.00.0040.00417.59
8.1.280.0120.00625.92
8.1.270.0050.00323.91
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0060.00322.73
8.1.230.0030.00717.57
8.1.220.0030.00617.74
8.1.210.0050.00318.77
8.1.200.0060.00317.25
8.1.190.0000.00817.35
8.1.180.0060.00318.10
8.1.170.0060.00318.61
8.1.160.0000.00821.98
8.1.150.0030.00518.66
8.1.140.0110.00017.33
8.1.130.0000.00817.76
8.1.120.0050.00217.39
8.1.110.0040.00417.34
8.1.100.0040.00417.50
8.1.90.0040.00417.36
8.1.80.0030.00317.52
8.1.70.0030.00317.51
8.1.60.0000.00817.56
8.1.50.0000.00817.53
8.1.40.0040.00417.59
8.1.30.0000.00817.49
8.1.20.0000.00817.54
8.1.10.0000.00817.46
8.1.00.0040.00417.34
8.0.300.0070.00018.77
8.0.290.0040.00416.88
8.0.280.0000.00818.39
8.0.270.0000.00817.35
8.0.260.0000.00616.77
8.0.250.0030.00317.05
8.0.240.0040.00417.05
8.0.230.0030.00317.05
8.0.220.0030.00316.99
8.0.210.0000.00817.00
8.0.200.0000.00717.02
8.0.190.0040.00417.11
8.0.180.0030.00517.01
8.0.170.0050.00317.02
8.0.160.0030.00616.89
8.0.150.0080.00316.88
8.0.140.0070.00016.81
8.0.130.0030.00313.50
8.0.120.0000.00816.86
8.0.110.0000.01016.98
8.0.100.0040.00416.95
8.0.90.0070.00016.88
8.0.80.0100.00717.05
8.0.70.0040.00416.86
8.0.60.0000.00816.86
8.0.50.0060.00317.10
8.0.30.0100.00916.96
8.0.20.0120.01017.40
8.0.10.0040.00416.92
8.0.00.0100.01016.87
7.4.330.0000.00515.09
7.4.320.0000.00716.67
7.4.300.0030.00316.58
7.4.290.0000.00716.63
7.4.280.0070.00016.57
7.4.270.0040.00416.70
7.4.260.0040.00416.72
7.4.250.0080.00016.54
7.4.240.0000.00816.68
7.4.230.0030.00416.71
7.4.220.0060.01216.66
7.4.210.0110.00616.72
7.4.200.0000.00716.59
7.4.190.0050.00316.64
7.4.160.0110.00616.65
7.4.150.0060.01217.40
7.4.140.0070.01117.86
7.4.130.0100.00816.62
7.4.120.0110.00616.63
7.4.110.0100.00716.58
7.4.100.0080.01116.61
7.4.90.0120.00616.59
7.4.80.0090.01016.56
7.4.70.0100.00616.51
7.4.60.0100.00716.59
7.4.50.0080.00016.64
7.4.40.0060.00822.77
7.4.30.0070.01016.63
7.4.00.0080.01014.87
7.3.330.0030.00313.37
7.3.320.0000.00513.43
7.3.310.0000.00716.30
7.3.300.0000.00716.36
7.3.290.0110.00416.49
7.3.280.0100.00716.37
7.3.270.0060.01217.40
7.3.260.0060.01216.38
7.3.250.0040.01416.68
7.3.240.0110.01116.70
7.3.230.0080.00816.41
7.3.210.0160.00316.63
7.3.200.0090.00919.39
7.3.190.0060.01016.54
7.3.180.0170.00016.61
7.3.170.0160.00616.43
7.3.160.0110.00616.55
7.3.120.0030.01114.92
7.3.110.0070.00714.57
7.3.100.0070.00714.98
7.3.90.0100.00015.21
7.3.80.0030.01514.91
7.3.70.0070.01014.74
7.3.60.0030.01014.97
7.3.50.0070.00714.75
7.3.40.0040.01114.95
7.3.30.0000.00914.86
7.3.20.0070.01116.52
7.3.10.0100.00616.72
7.3.00.0100.00516.61
7.2.330.0130.00616.56
7.2.320.0070.01716.61
7.2.310.0090.01216.90
7.2.300.0170.00816.59
7.2.290.0060.01216.58
7.2.250.0110.00415.36
7.2.240.0030.01615.35
7.2.230.0030.01215.18
7.2.220.0000.00915.09
7.2.210.0000.01815.16
7.2.200.0040.01215.09
7.2.190.0030.01014.88
7.2.180.0090.00015.16
7.2.170.0030.01315.01
7.2.130.0120.00716.58
7.2.120.0110.00916.75
7.2.110.0100.00616.73
7.2.100.0090.00716.67
7.2.90.0120.00316.64
7.2.80.0080.01116.73
7.2.70.0100.00516.49
7.2.60.0100.00916.78
7.2.50.0150.00216.70
7.2.40.0120.00516.60
7.2.30.0110.00316.46
7.2.20.0080.00916.78
7.2.10.0110.00516.79
7.2.00.0070.00917.78
7.1.330.0070.00715.79
7.1.320.0080.00815.63
7.1.310.0040.00715.88
7.1.300.0130.00315.70
7.1.290.0070.00715.74
7.1.280.0090.00615.54
7.1.270.0030.00915.76
7.1.260.0060.00915.83
7.1.250.0060.00715.53
7.1.200.0030.00915.85
7.1.100.0080.00818.02
7.1.70.0140.00017.29
7.1.60.0070.01419.27
7.1.50.0140.01116.96
7.1.00.0070.07022.27
7.0.200.0070.00316.85
7.0.140.0100.07021.95
7.0.100.0070.08320.01
7.0.90.0070.08320.12
7.0.80.0070.08019.93
7.0.70.0200.06719.89
7.0.60.0070.08320.00
7.0.50.0030.05320.47
7.0.40.0200.06720.08
7.0.30.0100.07720.03
7.0.20.0200.07720.13
7.0.10.0000.05720.10
7.0.00.0130.08020.08
5.6.280.0070.07320.86
5.6.250.0030.05320.71
5.6.240.0100.04320.74
5.6.230.0100.07320.73
5.6.220.0070.07720.67
5.6.210.0000.06720.65
5.6.200.0130.08021.16
5.6.190.0030.09321.04
5.6.180.0100.08321.13
5.6.170.0100.07021.00
5.6.160.0130.07721.10
5.6.150.0070.08721.13
5.6.140.0070.07021.06
5.6.130.0100.08320.99
5.6.120.0030.09021.10
5.6.110.0100.07721.11
5.6.100.0200.06721.11
5.6.90.0100.08021.07
5.6.80.0130.06720.55
5.6.70.0100.07320.36
5.6.60.0070.08320.44
5.6.50.0100.07720.45
5.6.40.0100.07320.48
5.6.30.0170.05720.46
5.6.20.0130.08020.51
5.6.10.0070.07320.41
5.6.00.0070.07320.45
5.5.380.0170.06720.45
5.5.370.0100.08020.47
5.5.360.0100.07320.44
5.5.350.0070.08320.44
5.5.340.0130.07020.91
5.5.330.0170.06720.97
5.5.320.0130.07020.91
5.5.310.0130.07320.98
5.5.300.0000.09020.89
5.5.290.0130.07720.95
5.5.280.0100.08020.91
5.5.270.0070.07320.80
5.5.260.0100.06320.88
5.5.250.0030.08720.72
5.5.240.0100.05320.35
5.5.230.0100.07320.04
5.5.220.0070.07320.31
5.5.210.0030.05720.16
5.5.200.0170.07320.34
5.5.190.0100.04720.32
5.5.180.0100.07720.20
5.5.160.0070.08020.23
5.5.150.0070.07320.04
5.5.140.0170.06320.16
5.5.130.0030.08320.28
5.5.120.0100.06720.22
5.5.110.0070.07720.16
5.5.100.0100.07720.21
5.5.90.0170.07019.99
5.5.80.0070.08320.17
5.5.70.0100.06320.17
5.5.60.0200.06320.20
5.5.50.0170.06320.20
5.5.40.0070.07720.11
5.5.30.0100.07320.14
5.5.20.0030.08020.07
5.5.10.0030.07720.16
5.5.00.0070.08020.05
5.4.450.0070.08719.18
5.4.440.0030.08319.45
5.4.430.0000.08719.45
5.4.420.0000.08019.45
5.4.410.0100.07719.32
5.4.400.0130.03019.09
5.4.390.0030.08319.13
5.4.380.0100.07319.12
5.4.370.0070.07318.85
5.4.360.0100.07318.89
5.4.350.0070.07719.05
5.4.340.0030.08318.90
5.4.320.0030.08318.86
5.4.310.0100.07318.95
5.4.300.0100.07019.14
5.4.290.0100.07319.21
5.4.280.0030.07019.13
5.4.270.0130.06718.85
5.4.260.0170.06019.21
5.4.250.0000.08719.12
5.4.240.0070.07719.04
5.4.230.0070.07319.03
5.4.220.0030.07719.16
5.4.210.0100.07318.89
5.4.200.0170.06318.84
5.4.190.0030.08019.18
5.4.180.0000.05019.02
5.4.170.0130.07018.88
5.4.160.0000.05019.01
5.4.150.0070.07319.16
5.4.140.0030.08016.52
5.4.130.0100.06716.46
5.4.120.0000.07316.47
5.4.110.0070.07316.55
5.4.100.0030.03716.44
5.4.90.0130.06716.55
5.4.80.0070.05716.33
5.4.70.0030.07716.52
5.4.60.0070.07316.52
5.4.50.0070.06716.42
5.4.40.0070.07016.32
5.4.30.0070.06316.44
5.4.20.0070.06716.46
5.4.10.0130.06016.52
5.4.00.0070.07015.69
5.3.290.0100.07314.76
5.3.280.0100.07314.61
5.3.270.0170.06714.73
5.3.260.0030.08014.68
5.3.250.0070.07314.80
5.3.240.0070.07314.61
5.3.230.0100.07314.72
5.3.220.0100.04314.62
5.3.210.0100.07014.69
5.3.200.0030.06314.61
5.3.190.0030.08014.57
5.3.180.0070.07714.74
5.3.170.0100.06014.75
5.3.160.0100.06714.64
5.3.150.0100.07014.65
5.3.140.0030.04314.55
5.3.130.0030.07714.54
5.3.120.0100.07314.59
5.3.110.0100.07314.73
5.3.100.0100.07314.24
5.3.90.0200.05714.24
5.3.80.0030.07314.24
5.3.70.0030.08314.24
5.3.60.0170.06714.24
5.3.50.0070.07014.24
5.3.40.0070.05714.24
5.3.30.0000.06714.24
5.3.20.0030.07314.24
5.3.10.0070.07014.24
5.3.00.0000.05014.24

preferences:
38.57 ms | 401 KiB | 5 Q