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); } 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.70.0100.01318.28
8.3.60.0030.01416.75
8.3.50.0110.01117.40
8.3.40.0060.01018.82
8.3.30.0110.00718.76
8.3.20.0080.00018.73
8.3.10.0130.00318.59
8.3.00.0060.00319.13
8.2.180.0110.01116.75
8.2.170.0040.01122.96
8.2.160.0140.00319.13
8.2.150.0090.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0080.00020.66
8.2.110.0030.00722.28
8.2.100.0080.00317.97
8.2.90.0000.00819.36
8.2.80.0000.00817.97
8.2.70.0040.00417.63
8.2.60.0060.00318.03
8.2.50.0080.00018.07
8.2.40.0030.00618.28
8.2.30.0040.00417.76
8.2.20.0000.00817.59
8.2.10.0000.00817.64
8.2.00.0050.00317.65
8.1.280.0090.00625.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0000.00821.15
8.1.230.0040.00717.58
8.1.220.0000.00817.78
8.1.210.0000.00918.77
8.1.200.0070.00317.35
8.1.190.0040.00417.35
8.1.180.0030.00518.10
8.1.170.0050.00320.48
8.1.160.0040.00418.93
8.1.150.0000.00718.71
8.1.140.0040.00417.48
8.1.130.0000.00717.44
8.1.120.0040.00417.49
8.1.110.0000.00817.41
8.1.100.0000.00717.38
8.1.90.0070.00017.46
8.1.80.0000.00817.45
8.1.70.0050.00317.49
8.1.60.0040.00417.59
8.1.50.0040.00417.55
8.1.40.0030.00517.61
8.1.30.0100.00017.69
8.1.20.0030.00517.59
8.1.10.0080.00017.49
8.1.00.0040.00417.41
8.0.300.0000.00718.77
8.0.290.0040.00416.75
8.0.280.0030.00318.48
8.0.270.0040.00417.35
8.0.260.0030.00316.91
8.0.250.0000.00717.09
8.0.240.0070.00017.08
8.0.230.0000.00716.95
8.0.220.0000.00816.95
8.0.210.0040.00416.98
8.0.200.0000.00716.93
8.0.190.0000.00717.05
8.0.180.0030.00617.03
8.0.170.0030.00616.90
8.0.160.0050.00316.95
8.0.150.0000.00816.85
8.0.140.0040.00416.83
8.0.130.0030.00313.42
8.0.120.0030.00616.88
8.0.110.0000.00716.98
8.0.100.0030.00616.95
8.0.90.0050.00217.00
8.0.80.0090.00617.00
8.0.70.0050.00316.98
8.0.60.0000.00817.03
8.0.50.0080.00016.78
8.0.30.0090.00916.95
8.0.20.0140.00717.15
8.0.10.0070.00017.13
8.0.00.0070.01116.94
7.4.330.0030.00312.98
7.4.320.0030.00316.69
7.4.300.0040.00416.61
7.4.290.0000.00716.54
7.4.280.0030.00616.61
7.4.270.0040.00416.64
7.4.260.0050.00013.46
7.4.250.0000.00716.44
7.4.240.0040.00416.55
7.4.230.0070.00316.48
7.4.220.0160.01016.72
7.4.210.0140.00716.56
7.4.200.0030.00616.67
7.4.190.0040.00416.57
7.4.160.0080.00816.62
7.4.150.0140.00416.82
7.4.140.0130.00616.70
7.4.130.0030.02216.71
7.4.120.0100.01316.48
7.4.110.0070.01316.76
7.4.100.0070.01516.57
7.4.90.0040.01416.60
7.4.80.0030.01619.39
7.4.70.0070.01016.62
7.4.60.0070.00916.52
7.4.50.0060.00316.56
7.4.40.0100.00616.26
7.4.30.0130.00616.48
7.4.10.0100.00615.32
7.4.00.0090.00815.03
7.3.330.0000.00713.52
7.3.320.0050.00013.25
7.3.310.0000.00716.41
7.3.300.0030.00316.62
7.3.290.0090.00816.47
7.3.280.0110.01116.54
7.3.270.0150.00316.52
7.3.260.0130.01016.61
7.3.250.0110.00916.49
7.3.240.0060.01216.71
7.3.230.0080.00816.56
7.3.210.0070.01016.71
7.3.200.0110.00616.53
7.3.190.0070.01116.57
7.3.180.0170.00016.79
7.3.170.0060.01116.61
7.3.160.0100.01016.56
7.3.130.0060.01214.91
7.3.120.0070.00914.83
7.3.110.0110.00814.82
7.3.100.0070.00714.80
7.3.90.0040.01014.91
7.3.80.0080.00514.95
7.3.70.0040.01014.87
7.3.60.0040.00914.76
7.3.50.0020.01215.00
7.3.40.0070.00414.95
7.3.30.0030.01014.78
7.3.20.0030.00916.63
7.3.10.0030.00916.51
7.3.00.0050.00716.61
7.2.330.0110.00916.48
7.2.320.0060.01216.93
7.2.310.0090.00816.94
7.2.300.0090.01516.93
7.2.290.0110.00816.88
7.2.260.0040.01414.97
7.2.250.0080.01015.27
7.2.240.0110.00715.11
7.2.230.0050.00814.76
7.2.220.0110.00615.09
7.2.210.0070.00915.15
7.2.200.0090.00815.11
7.2.190.0080.00814.96
7.2.180.0050.00815.17
7.2.170.0060.00715.28
7.2.160.0090.00615.11
7.2.150.0030.00917.04
7.2.140.0000.01316.92
7.2.130.0000.01416.92
7.2.120.0040.01116.86
7.2.110.0110.00417.02
7.2.100.0090.00616.88
7.2.90.0030.01116.94
7.2.80.0100.00316.88
7.2.70.0000.01217.13
7.2.60.0060.00916.73
7.2.50.0030.00617.01
7.2.40.0040.01216.71
7.2.30.0130.00317.01
7.2.20.0110.00317.00
7.2.10.0040.01116.77
7.2.00.0050.01018.21
7.1.330.0070.01015.56
7.1.320.0030.01115.59
7.1.310.0040.00715.81
7.1.300.0060.00815.84
7.1.290.0040.01015.92
7.1.280.0080.00415.68
7.1.270.0030.01015.89
7.1.260.0080.00615.75
7.1.250.0030.01015.83
7.1.240.0030.00615.58
7.1.230.0060.00615.64
7.1.220.0070.00715.71
7.1.210.0060.00615.71
7.1.200.0060.00715.71
7.1.190.0000.01115.79
7.1.180.0040.00715.58
7.1.170.0070.00415.80
7.1.160.0120.00315.94
7.1.150.0000.01015.97
7.1.140.0060.00915.72
7.1.130.0070.00315.54
7.1.120.0100.00315.81
7.1.110.0000.01215.84
7.1.100.0150.00716.55
7.1.90.0030.01015.83
7.1.80.0070.00715.98
7.1.70.0030.00816.64
7.1.60.0050.01317.52
7.1.50.0060.00816.47
7.1.40.0040.00715.93
7.1.30.0050.00515.59
7.1.20.0000.01515.82
7.1.10.0040.01116.01
7.1.00.0040.04519.02
7.0.330.0140.00015.34
7.0.320.0070.00715.29
7.0.310.0120.00415.36
7.0.300.0110.00315.45
7.0.290.0000.00915.38
7.0.280.0070.00715.39
7.0.270.0080.00415.32
7.0.260.0080.00415.23
7.0.250.0030.00815.52
7.0.240.0100.00315.56
7.0.230.0070.00715.64
7.0.220.0060.00915.33
7.0.210.0000.00815.50
7.0.200.0050.00616.19
7.0.190.0000.01315.36
7.0.180.0030.00715.28
7.0.170.0070.00715.38
7.0.160.0000.01015.40
7.0.150.0110.00415.60
7.0.140.0040.03718.80
7.0.130.0070.00415.45
7.0.120.0030.03618.77
7.0.110.0030.03518.55
7.0.100.0070.02218.51
7.0.90.0000.02718.49
7.0.80.0050.02918.60
7.0.70.0030.04318.59
7.0.60.0030.03218.47
7.0.50.0050.02418.78
7.0.40.0060.02016.93
7.0.30.0030.02617.04
7.0.20.0000.02616.93
7.0.10.0030.02517.03
7.0.00.0030.03416.99
5.6.400.0040.01114.82
5.6.390.0070.00714.66
5.6.380.0030.00614.27
5.6.370.0000.01514.17
5.6.360.0040.01114.86
5.6.350.0100.00314.54
5.6.340.0060.00614.54
5.6.330.0070.01014.41
5.6.320.0140.00014.60
5.6.310.0000.00914.54
5.6.300.0000.01114.57
5.6.290.0080.00614.67
5.6.280.0020.04317.81
5.6.270.0060.00614.36
5.6.260.0050.02217.58
5.6.250.0030.02517.69
5.6.240.0040.02517.55
5.6.230.0020.03817.72
5.6.220.0030.03017.61
5.6.210.0020.02717.54
5.6.200.0010.02817.93
5.6.190.0020.03017.78
5.6.180.0060.02017.75
5.6.170.0050.02417.73
5.6.160.0000.03517.82
5.6.150.0070.02117.99
5.6.140.0040.01917.73
5.6.130.0030.02417.62
5.6.120.0050.03818.01
5.6.110.0020.03317.75
5.6.100.0020.04217.85
5.6.90.0060.02117.86
5.6.80.0050.02217.51
5.6.70.0000.03417.44
5.6.60.0100.03717.42
5.6.50.0050.04217.38
5.6.40.0020.03217.33
5.6.30.0000.04017.56
5.6.20.0020.03917.39
5.6.10.0020.03017.43
5.6.00.0050.04317.41
5.5.380.0030.02517.47
5.5.370.0020.02917.68
5.5.360.0050.02517.53
5.5.350.0030.04617.51
5.5.340.0060.02317.61
5.5.330.0020.02617.88
5.5.320.0000.02917.77
5.5.310.0050.02117.74
5.5.300.0060.02017.61
5.5.290.0020.03017.63
5.5.280.0060.02717.71
5.5.270.0030.03017.81
5.5.260.0030.03617.86
5.5.250.0020.02617.56
5.5.240.0050.02117.40
5.5.230.0030.04317.42
5.5.220.0030.04517.42
5.5.210.0060.04117.38
5.5.200.0020.04117.31
5.5.190.0050.04517.26
5.5.180.0040.02917.28
5.5.170.0030.01014.37
5.5.160.0050.04317.33
5.5.150.0020.02617.37
5.5.140.0050.04217.18
5.5.130.0050.04317.23
5.5.120.0080.04117.45
5.5.110.0030.04517.35
5.5.100.0050.04217.37
5.5.90.0020.04617.30
5.5.80.0050.04217.40
5.5.70.0050.04317.21
5.5.60.0030.04217.47
5.5.50.0030.04217.38
5.5.40.0060.04117.44
5.5.30.0080.03817.35
5.5.20.0030.04317.36
5.5.10.0040.04717.07
5.5.00.0050.03917.43
5.4.450.0030.02416.59
5.4.440.0070.03316.70
5.4.430.0030.02216.55
5.4.420.0030.02316.66
5.4.410.0050.03216.68
5.4.400.0030.02516.51
5.4.390.0050.01816.60
5.4.380.0030.04116.44
5.4.370.0070.03516.43
5.4.360.0000.04616.43
5.4.350.0000.04416.55
5.4.340.0070.04216.51
5.4.330.0060.00613.85
5.4.320.0060.01916.43
5.4.310.0030.03216.42
5.4.300.0060.03816.40
5.4.290.0090.03316.49
5.4.280.0000.04216.52
5.4.270.0050.04216.58
5.4.260.0020.04216.54
5.4.250.0070.03816.42
5.4.240.0020.04116.51
5.4.230.0040.04016.54
5.4.220.0020.04516.47
5.4.210.0080.03716.43
5.4.200.0070.03816.43
5.4.190.0030.04316.51
5.4.180.0080.02016.50
5.4.170.0010.03416.51
5.4.160.0080.03716.58
5.4.150.0050.04016.42
5.4.140.0090.03815.14
5.4.130.0040.02715.21
5.4.120.0020.03515.08
5.4.110.0030.04015.28
5.4.100.0030.03715.28
5.4.90.0080.03315.27
5.4.80.0030.04015.16
5.4.70.0030.04115.15
5.4.60.0080.03515.23
5.4.50.0030.04015.21
5.4.40.0020.03715.14
5.4.30.0040.03415.22
5.4.20.0050.03515.23
5.4.10.0000.04515.26
5.4.00.0060.03514.85
5.3.290.0020.04414.33
5.3.280.0030.03314.37
5.3.270.0050.03714.26
5.3.260.0020.03714.28
5.3.250.0050.03814.33
5.3.240.0000.04614.26
5.3.230.0080.03514.37
5.3.220.0030.04014.25
5.3.210.0020.04014.24
5.3.200.0050.04014.26
5.3.190.0050.04014.25
5.3.180.0080.03514.21
5.3.170.0030.04114.30
5.3.160.0030.04214.30
5.3.150.0100.03014.30
5.3.140.0070.03814.26
5.3.130.0050.04314.23
5.3.120.0030.04014.23
5.3.110.0090.02714.29
5.3.100.0040.02613.98
5.3.90.0030.03113.96
5.3.80.0060.03614.01
5.3.70.0010.04114.03
5.3.60.0020.04213.99
5.3.50.0040.04013.93
5.3.40.0020.03813.94
5.3.30.0040.03713.95
5.3.20.0030.03113.81
5.3.10.0030.03913.78
5.3.00.0060.03513.78

preferences:
67.42 ms | 401 KiB | 5 Q