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, "=")) { $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) { $attr = array(); } else { foreach($this->attr as $try) { if ($try->Name() === $name) { unset($try); } } unset($attr[$name]); } } 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 ). "'"))); } } $element = new Element("a"); $element->AddAttr(new Attribute("href", "http://google.nl")); $element->AddAttr(new Attribute("target", "_blank")); $element2 = new Element("span"); $element2->AddAttr(new Attribute("style", array("color" => "orange","background-color" => "green"))); $element2->Value("doei"); $element2->AttrFromString("required"); $element3 = new Element("img", true); $element->SetAttr("href", "http://twitter.com"); $element3->AddAttr(new Attribute("src", "https://si0.twimg.com/profile_images/3439429669/c2c9d02095be44d026d358e0a39bced0_normal.jpeg")); $element->RemoveAttr("href"); $element->Value($element2 . NewLine. "hoi" .NewLine . $element3); echo $element;

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.0090.00616.63
8.3.50.0130.01022.04
8.3.40.0120.00318.81
8.3.30.0110.00318.92
8.3.20.0000.00820.37
8.3.10.0090.00023.66
8.3.00.0100.00017.25
8.2.180.0140.00718.54
8.2.170.0120.00322.96
8.2.160.0070.00720.47
8.2.150.0040.00424.18
8.2.140.0030.00524.66
8.2.130.0040.01126.16
8.2.120.0000.00822.08
8.2.110.0030.00621.17
8.2.100.0060.00617.91
8.2.90.0040.00419.21
8.2.80.0060.00617.97
8.2.70.0060.00317.75
8.2.60.0040.00418.03
8.2.50.0000.00818.10
8.2.40.0000.00818.02
8.2.30.0030.00618.13
8.2.20.0040.00417.68
8.2.10.0000.00818.08
8.2.00.0070.00317.79
8.1.280.0120.00325.92
8.1.270.0030.00622.18
8.1.260.0040.00426.35
8.1.250.0070.00028.09
8.1.240.0050.00522.80
8.1.230.0060.00617.83
8.1.220.0040.00417.74
8.1.210.0030.00518.77
8.1.200.0030.00617.35
8.1.190.0060.00317.35
8.1.180.0000.00818.10
8.1.170.0050.00518.46
8.1.160.0060.00322.03
8.1.150.0030.00518.66
8.1.140.0000.00717.43
8.1.130.0030.00317.84
8.1.120.0080.00017.38
8.1.110.0070.00017.45
8.1.100.0040.00417.52
8.1.90.0000.00717.41
8.1.80.0000.00717.38
8.1.70.0030.00317.45
8.1.60.0030.00517.49
8.1.50.0040.00417.53
8.1.40.0060.00317.51
8.1.30.0000.00817.64
8.1.20.0060.00317.64
8.1.10.0030.00617.46
8.1.00.0050.00317.44
8.0.300.0080.00018.77
8.0.290.0090.00016.88
8.0.280.0000.00718.46
8.0.270.0070.00017.33
8.0.260.0000.00717.20
8.0.250.0000.00716.88
8.0.240.0000.00717.04
8.0.230.0040.00417.08
8.0.220.0040.00417.00
8.0.210.0000.00717.01
8.0.200.0000.00717.06
8.0.190.0000.00817.04
8.0.180.0000.00917.01
8.0.170.0040.00416.99
8.0.160.0000.00817.05
8.0.150.0070.00016.96
8.0.140.0000.00716.88
8.0.130.0000.00613.35
8.0.120.0040.00416.83
8.0.110.0060.00316.82
8.0.100.0040.00416.98
8.0.90.0040.00417.00
8.0.80.0040.01416.88
8.0.70.0070.00016.93
8.0.60.0040.00416.77
8.0.50.0040.00416.84
8.0.30.0120.00617.03
8.0.20.0100.00917.40
8.0.10.0000.00716.93
8.0.00.0070.01016.71
7.4.330.0080.00015.15
7.4.320.0070.00016.64
7.4.300.0040.00416.74
7.4.290.0000.00716.59
7.4.280.0000.00816.57
7.4.270.0000.00816.55
7.4.260.0030.00516.63
7.4.250.0050.00316.55
7.4.240.0040.00416.57
7.4.230.0050.00216.52
7.4.220.0200.00716.73
7.4.210.0100.00416.66
7.4.200.0070.00016.68
7.4.190.0040.00416.82
7.4.160.0080.00816.45
7.4.150.0120.00617.40
7.4.140.0030.01317.86
7.4.130.0080.00816.70
7.4.120.0100.00916.63
7.4.110.0130.01016.45
7.4.100.0110.00816.58
7.4.90.0070.01116.81
7.4.80.0060.01219.39
7.4.70.0030.01316.63
7.4.60.0090.00816.67
7.4.50.0000.00616.68
7.4.40.0030.01022.77
7.4.30.0140.00316.67
7.4.10.0040.01215.02
7.4.00.0050.01214.80
7.3.330.0060.00013.35
7.3.320.0030.00413.47
7.3.310.0030.00416.52
7.3.300.0000.00716.36
7.3.290.0120.00616.48
7.3.280.0040.01316.49
7.3.270.0150.00317.40
7.3.260.0130.01016.52
7.3.250.0120.00816.56
7.3.240.0070.01016.43
7.3.230.0140.00616.68
7.3.210.0130.00516.39
7.3.200.0070.01319.39
7.3.190.0060.01516.58
7.3.180.0100.00616.66
7.3.170.0090.00916.75
7.3.160.0160.00016.54
7.3.130.0030.01314.98
7.3.120.0040.01114.87
7.3.110.0060.01314.98
7.3.100.0000.01514.73
7.3.90.0060.01014.99
7.3.80.0060.00614.73
7.3.70.0100.00614.78
7.3.60.0000.01415.07
7.3.50.0000.01114.99
7.3.40.0070.00714.84
7.3.30.0030.00914.77
7.3.20.0070.00716.57
7.3.10.0040.00816.52
7.3.00.0060.00616.84
7.2.330.0030.01416.56
7.2.320.0090.00916.58
7.2.310.0130.00416.87
7.2.300.0090.01316.66
7.2.290.0030.01316.54
7.2.260.0000.01514.97
7.2.250.0070.01015.35
7.2.240.0000.01515.00
7.2.230.0100.00715.36
7.2.220.0060.00915.16
7.2.210.0040.00815.14
7.2.200.0060.00914.87
7.2.190.0040.00714.88
7.2.180.0090.00415.09
7.2.170.0040.00814.88
7.2.160.0040.01415.16
7.2.150.0070.00716.81
7.2.140.0100.00717.04
7.2.130.0100.00317.05
7.2.120.0040.00816.70
7.2.110.0100.00016.70
7.2.100.0040.01516.95
7.2.90.0040.01117.16
7.2.80.0090.00916.99
7.2.70.0070.00717.21
7.2.60.0030.01417.04
7.2.50.0060.00916.65
7.2.40.0100.00316.76
7.2.30.0000.01017.04
7.2.20.0070.01017.00
7.2.10.0000.01716.93
7.2.00.0040.01117.09
7.1.330.0030.01315.82
7.1.320.0040.00915.84
7.1.310.0070.00715.80
7.1.300.0040.00815.80
7.1.290.0120.00015.55
7.1.280.0070.00715.44
7.1.270.0000.01315.62
7.1.260.0060.01015.69
7.1.250.0000.00915.78
7.1.240.0060.01015.85
7.1.230.0090.00615.82
7.1.220.0040.01115.67
7.1.210.0040.00815.86
7.1.200.0060.00615.94
7.1.190.0080.00815.76
7.1.180.0080.00615.70
7.1.170.0000.01116.00
7.1.160.0040.01115.77
7.1.150.0070.00315.64
7.1.140.0060.00615.90
7.1.130.0100.00615.61
7.1.120.0030.01015.46
7.1.110.0070.00315.50
7.1.100.0070.00715.52
7.1.90.0130.00315.59
7.1.80.0130.00015.97
7.1.70.0050.00916.48
7.1.60.0070.01217.56
7.1.50.0120.01325.29
7.1.40.0110.00715.69
7.1.30.0060.00315.84
7.1.20.0070.00715.87
7.1.10.0120.00315.79
7.1.00.0090.03719.10
7.0.330.0000.00915.11
7.0.320.0040.01115.43
7.0.310.0040.01515.49
7.0.300.0040.00415.45
7.0.290.0030.00615.53
7.0.280.0070.00715.30
7.0.270.0100.00715.40
7.0.260.0030.00615.45
7.0.250.0030.01315.52
7.0.240.0030.01415.20
7.0.230.0070.00715.61
7.0.220.0000.01015.18
7.0.210.0030.01215.34
7.0.200.0090.00516.17
7.0.190.0040.01515.39
7.0.180.0080.00415.55
7.0.170.0000.00815.53
7.0.160.0000.00915.59
7.0.150.0100.00715.55
7.0.140.0050.04018.68
7.0.130.0070.00715.51
7.0.120.0120.00315.21
7.0.110.0040.01115.47
7.0.100.0220.03917.73
7.0.90.0050.03817.62
7.0.80.0150.02817.61
7.0.70.0200.03817.79
7.0.60.0070.01917.76
7.0.50.0240.04517.99
7.0.40.0070.04716.85
7.0.30.0160.02516.88
7.0.20.0080.04816.85
7.0.10.0080.04716.73
7.0.00.0100.02816.69
5.6.400.0030.01014.41
5.6.390.0030.00714.45
5.6.380.0030.01314.57
5.6.370.0030.01314.58
5.6.360.0070.00314.52
5.6.350.0060.00914.57
5.6.340.0000.01414.46
5.6.330.0070.01014.45
5.6.320.0080.01114.39
5.6.310.0070.00714.55
5.6.300.0000.01114.65
5.6.290.0060.00614.73
5.6.280.0040.04217.83
5.6.270.0030.00914.84
5.6.260.0070.01114.74
5.6.250.0060.03817.67
5.6.240.0110.04717.63
5.6.230.0030.02717.69
5.6.220.0070.04317.79
5.6.210.0040.04417.55
5.6.200.0090.04217.80
5.6.190.0050.04217.94
5.6.180.0150.03717.71
5.6.170.0050.04017.74
5.6.160.0030.04617.72
5.6.150.0020.02917.80
5.6.140.0060.04017.91
5.6.130.0050.02617.69
5.6.120.0080.04517.87
5.6.110.0070.04917.74
5.6.100.0070.02517.85
5.6.90.0110.02017.70
5.6.80.0050.02717.43
5.6.70.0100.05017.44
5.6.60.0030.03917.60
5.6.50.0050.03317.40
5.6.40.0030.03617.57
5.6.30.0070.02117.53
5.6.20.0080.03117.49
5.6.10.0080.03317.43
5.6.00.0080.02517.44
5.5.380.0080.02717.50
5.5.370.0070.03417.56
5.5.360.0060.02517.55
5.5.350.0100.02017.37
5.5.340.0120.01917.72
5.5.330.0050.04017.83
5.5.320.0130.03517.79
5.5.310.0130.03617.61
5.5.300.0100.02517.76
5.5.290.0020.05417.82
5.5.280.0070.03717.68
5.5.270.0040.04117.70
5.5.260.0050.04817.61
5.5.250.0100.03717.60
5.5.240.0070.04517.40
5.5.230.0100.03817.40
5.5.220.0050.04517.31
5.5.210.0100.04017.46
5.5.200.0100.03917.30
5.5.190.0080.04317.43
5.5.180.0050.04517.29
5.5.170.0030.00714.63
5.5.160.0100.03517.38
5.5.150.0060.02817.41
5.5.140.0120.03517.31
5.5.130.0080.04317.31
5.5.120.0070.04017.44
5.5.110.0050.04317.33
5.5.100.0090.03017.47
5.5.90.0020.02617.31
5.5.80.0050.03017.13
5.5.70.0050.03217.22
5.5.60.0000.03117.16
5.5.50.0110.03117.18
5.5.40.0080.03517.42
5.5.30.0100.03517.29
5.5.20.0060.03117.09
5.5.10.0000.03217.29
5.5.00.0070.02117.31
5.4.450.0080.02315.73
5.4.440.0050.04015.78
5.4.430.0030.03915.79
5.4.420.0080.04015.79
5.4.410.0090.04015.69
5.4.400.0090.02415.61
5.4.390.0040.02315.48
5.4.380.0070.02115.48
5.4.370.0020.02215.61
5.4.360.0020.02215.59
5.4.350.0090.03015.65
5.4.340.0030.02215.61
5.4.330.0030.00312.09
5.4.320.0070.03015.59
5.4.310.0070.03315.52
5.4.300.0100.03815.56
5.4.290.0100.03515.65
5.4.280.0050.03515.52
5.4.270.0070.02215.56
5.4.260.0050.04315.48
5.4.250.0030.02315.47
5.4.240.0100.02815.52
5.4.230.0080.03815.60
5.4.220.0110.03515.52
5.4.210.0070.04415.57
5.4.200.0080.03815.52
5.4.190.0050.04615.62
5.4.180.0090.03815.64
5.4.170.0070.02715.59
5.4.160.0080.04115.56
5.4.150.0020.03915.61
5.4.140.0020.04114.30
5.4.130.0050.03914.18
5.4.120.0050.04314.26
5.4.110.0030.04014.29
5.4.100.0070.04014.33
5.4.90.0050.02514.32
5.4.80.0050.03514.28
5.4.70.0020.03614.25
5.4.60.0070.02014.30
5.4.50.0030.02514.28
5.4.40.0100.02814.28
5.4.30.0080.02414.27
5.4.20.0000.04614.28
5.4.10.0050.02414.29
5.4.00.0050.03714.01
5.3.290.0030.03013.38
5.3.280.0100.03313.34
5.3.270.0050.04113.41
5.3.260.0080.04013.39
5.3.250.0080.02613.34
5.3.240.0080.02113.42
5.3.230.0030.04513.45
5.3.220.0080.02313.43
5.3.210.0050.02513.39
5.3.200.0050.04313.39
5.3.190.0040.04413.37
5.3.180.0050.03313.35
5.3.170.0100.03713.40
5.3.160.0070.04013.36
5.3.150.0020.03213.43
5.3.140.0030.02313.32
5.3.130.0020.04313.39
5.3.120.0120.03513.34
5.3.110.0100.03813.39
5.3.100.0070.04213.10
5.3.90.0050.04013.07
5.3.80.0020.02513.14
5.3.70.0070.02613.13
5.3.60.0070.02013.04
5.3.50.0020.02813.08
5.3.40.0080.03813.11
5.3.30.0050.04013.03
5.3.20.0070.04112.88
5.3.10.0100.02812.96
5.3.00.0070.02712.95

preferences:
42.28 ms | 401 KiB | 5 Q