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 { return $this->attr[$name]; } } 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 SetAttr($name, $value) { $this->attr[$name] = $value; } public function RemoveAttr($name = null) { if ($name === null) { $attr = array(); } else { 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); $element3->AddAttr(new Attribute("src", "https://si0.twimg.com/profile_images/3439429669/c2c9d02095be44d026d358e0a39bced0_normal.jpeg")); $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.0120.00918.31
8.3.50.0170.00422.05
8.3.40.0080.00818.53
8.3.30.0000.01418.72
8.3.20.0040.00418.60
8.3.10.0000.00820.84
8.3.00.0040.00423.57
8.2.180.0090.00616.75
8.2.170.0070.00722.96
8.2.160.0070.00720.39
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0070.00026.16
8.2.120.0040.00421.04
8.2.110.0110.00020.39
8.2.100.0080.00417.72
8.2.90.0000.00819.05
8.2.80.0080.00018.03
8.2.70.0000.00917.50
8.2.60.0040.00417.80
8.2.50.0060.00318.07
8.2.40.0000.00818.03
8.2.30.0050.00319.79
8.2.20.0000.00717.72
8.2.10.0030.00617.63
8.2.00.0000.00817.69
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.0050.00522.29
8.1.230.0110.00021.09
8.1.220.0030.00518.77
8.1.210.0040.00419.01
8.1.200.0000.01017.13
8.1.190.0030.00517.63
8.1.180.0000.00818.10
8.1.170.0030.00518.59
8.1.160.0050.00218.90
8.1.150.0040.00418.55
8.1.140.0040.00417.46
8.1.130.0000.00717.84
8.1.120.0000.00717.54
8.1.110.0040.00417.35
8.1.100.0020.00517.45
8.1.90.0070.00017.48
8.1.80.0000.00717.38
8.1.70.0060.00317.48
8.1.60.0060.00317.52
8.1.50.0040.00417.55
8.1.40.0030.00617.53
8.1.30.0040.00417.61
8.1.20.0030.00617.75
8.1.10.0040.00417.38
8.1.00.0000.00817.45
8.0.300.0030.00520.10
8.0.290.0050.00217.30
8.0.280.0030.00518.50
8.0.270.0050.00517.16
8.0.260.0000.00716.90
8.0.250.0080.00017.00
8.0.240.0060.00317.10
8.0.230.0030.00316.97
8.0.220.0050.00316.93
8.0.210.0070.00016.99
8.0.200.0000.00617.00
8.0.190.0000.00817.03
8.0.180.0040.00416.95
8.0.170.0030.00617.02
8.0.160.0050.00216.99
8.0.150.0030.00516.98
8.0.140.0040.00816.89
8.0.130.0050.00013.36
8.0.120.0000.00917.02
8.0.110.0040.00417.09
8.0.100.0000.00816.98
8.0.90.0080.00016.91
8.0.80.0120.00316.85
8.0.70.0000.00716.84
8.0.60.0080.00016.87
8.0.50.0040.00416.84
8.0.30.0100.01317.13
8.0.20.0150.00817.40
8.0.10.0040.00416.98
8.0.00.0090.00916.93
7.4.330.0030.00314.65
7.4.320.0060.00016.58
7.4.300.0000.00716.44
7.4.290.0000.00816.69
7.4.280.0000.00716.67
7.4.270.0040.00316.59
7.4.260.0060.00013.35
7.4.250.0080.00016.50
7.4.240.0030.00416.69
7.4.230.0040.00416.71
7.4.220.0040.01416.52
7.4.210.0080.00716.59
7.4.200.0040.00416.61
7.4.190.0000.00716.48
7.4.160.0150.00816.60
7.4.150.0150.00917.40
7.4.140.0110.00817.86
7.4.130.0200.00516.60
7.4.120.0070.01016.60
7.4.110.0120.00616.79
7.4.100.0120.00816.61
7.4.90.0070.01016.51
7.4.80.0110.01319.37
7.4.70.0070.01016.66
7.4.60.0110.00616.62
7.4.50.0060.00316.48
7.4.40.0110.00822.52
7.4.30.0110.00616.51
7.4.10.0070.01114.98
7.4.00.0080.00814.94
7.3.330.0030.00313.55
7.3.320.0020.00513.45
7.3.310.0030.00316.27
7.3.300.0000.00616.31
7.3.290.0030.01316.46
7.3.280.0090.01016.43
7.3.270.0120.01217.40
7.3.260.0130.00718.24
7.3.250.0140.00616.59
7.3.240.0070.01016.35
7.3.230.0120.00616.72
7.3.210.0120.00916.46
7.3.200.0030.01319.39
7.3.190.0000.01716.37
7.3.180.0140.00316.49
7.3.170.0070.01016.42
7.3.160.0100.00716.67
7.3.130.0030.01414.86
7.3.120.0070.01015.03
7.3.110.0100.00714.87
7.3.100.0070.01014.90
7.3.90.0070.00714.89
7.3.80.0070.00514.87
7.3.70.0040.00814.79
7.3.60.0060.01014.89
7.3.50.0080.00614.90
7.3.40.0080.00614.81
7.3.30.0090.00314.98
7.3.20.0020.00916.62
7.3.10.0050.00816.70
7.3.00.0060.01016.72
7.2.330.0100.00716.66
7.2.320.0090.01416.63
7.2.310.0120.00616.88
7.2.300.0080.00816.86
7.2.290.0000.01816.57
7.2.260.0040.01514.95
7.2.250.0060.00914.99
7.2.240.0130.00415.05
7.2.230.0040.01015.05
7.2.220.0080.00315.09
7.2.210.0040.01115.26
7.2.200.0090.00715.13
7.2.190.0020.01115.21
7.2.180.0050.01014.94
7.2.170.0070.01015.18
7.2.160.0040.01315.09
7.2.150.0050.01016.88
7.2.140.0050.01117.00
7.2.130.0050.00916.88
7.2.120.0090.00617.01
7.2.110.0060.00716.95
7.2.100.0080.00516.96
7.2.90.0060.00717.01
7.2.80.0050.01116.74
7.2.70.0070.00916.96
7.2.60.0150.00817.05
7.2.50.0030.01016.78
7.2.40.0110.00717.09
7.2.30.0040.01117.02
7.2.20.0060.00817.02
7.2.10.0050.01117.04
7.2.00.0050.00817.85
7.1.330.0050.01015.86
7.1.320.0050.01315.83
7.1.310.0080.00615.79
7.1.300.0040.00915.70
7.1.290.0060.00915.80
7.1.280.0090.00515.86
7.1.270.0070.00715.52
7.1.260.0070.00715.68
7.1.250.0040.00715.88
7.1.240.0070.00415.91
7.1.230.0080.00515.96
7.1.220.0060.00615.98
7.1.210.0080.00415.85
7.1.200.0080.00315.85
7.1.190.0000.01415.95
7.1.180.0070.00715.68
7.1.170.0030.01015.61
7.1.160.0080.00415.66
7.1.150.0000.01315.81
7.1.140.0080.00415.88
7.1.130.0060.00915.96
7.1.120.0040.00715.58
7.1.110.0030.00815.74
7.1.100.0050.00816.96
7.1.90.0030.00615.60
7.1.80.0030.00715.59
7.1.70.0040.00616.55
7.1.60.0070.00416.45
7.1.50.0000.01216.48
7.1.40.0100.00315.79
7.1.30.0060.00615.63
7.1.20.0060.00615.95
7.1.10.0000.00915.57
7.1.00.0020.03019.15
7.0.330.0070.00315.64
7.0.320.0030.00615.39
7.0.310.0000.01215.55
7.0.300.0040.00715.62
7.0.290.0060.00615.24
7.0.280.0000.00815.53
7.0.270.0000.01315.46
7.0.260.0070.00715.08
7.0.250.0000.01215.40
7.0.240.0100.00315.40
7.0.230.0040.00715.27
7.0.220.0030.01015.50
7.0.210.0070.00415.18
7.0.200.0070.00816.09
7.0.190.0070.00315.10
7.0.180.0040.00715.22
7.0.170.0030.01015.46
7.0.160.0040.00815.65
7.0.150.0030.01015.29
7.0.140.0050.04018.59
7.0.130.0060.00615.16
7.0.120.0040.00815.41
7.0.110.0030.01015.52
7.0.100.0060.00915.17
7.0.90.0060.00615.43
7.0.80.0060.00615.46
7.0.70.0070.04218.57
7.0.60.0050.03218.53
7.0.50.0080.04318.79
7.0.40.0090.04516.68
7.0.30.0050.02416.73
7.0.20.0020.04716.65
7.0.10.0030.03216.84
7.0.00.0060.04216.73
5.6.400.0080.00814.60
5.6.390.0070.00714.32
5.6.380.0050.00514.14
5.6.370.0000.01114.22
5.6.360.0030.00614.48
5.6.350.0090.00614.71
5.6.340.0030.00914.59
5.6.330.0060.00614.64
5.6.320.0060.00914.79
5.6.310.0040.01114.53
5.6.300.0100.00614.48
5.6.290.0100.00314.50
5.6.280.0090.04717.76
5.6.270.0120.00014.78
5.6.260.0070.01014.45
5.6.250.0090.00614.65
5.6.240.0090.00614.57
5.6.230.0070.01114.69
5.6.220.0000.04317.67
5.6.210.0050.04717.58
5.6.200.0050.04717.81
5.6.190.0060.03117.81
5.6.180.0050.04817.73
5.6.170.0090.04417.76
5.6.160.0100.03817.82
5.6.150.0050.04317.85
5.6.140.0060.04517.88
5.6.130.0080.03217.84
5.6.120.0070.04717.78
5.6.110.0070.04617.68
5.6.100.0010.05417.89
5.6.90.0090.04617.85
5.6.80.0100.03617.39
5.6.70.0120.03717.45
5.6.60.0120.04017.51
5.6.50.0080.04217.50
5.6.40.0040.04417.56
5.6.30.0060.02417.59
5.6.20.0050.04017.43
5.6.10.0080.02717.44
5.6.00.0030.02517.37
5.5.380.0030.01014.50
5.5.370.0060.00614.30
5.5.360.0020.03417.32
5.5.350.0030.04617.40
5.5.340.0110.04017.61
5.5.330.0080.04317.64
5.5.320.0030.04817.63
5.5.310.0150.03717.43
5.5.300.0100.04217.70
5.5.290.0090.03017.43
5.5.280.0070.03917.64
5.5.270.0050.04517.82
5.5.260.0070.04517.66
5.5.250.0070.04517.46
5.5.240.0080.02317.35
5.5.230.0070.04417.12
5.5.220.0090.03417.27
5.5.210.0090.03717.28
5.5.200.0050.05017.45
5.5.190.0070.02517.38
5.5.180.0020.02817.36
5.5.170.0030.00914.36
5.5.160.0100.03017.26
5.5.150.0020.02717.40
5.5.140.0100.02517.33
5.5.130.0020.02617.39
5.5.120.0050.02317.30
5.5.110.0040.02317.37
5.5.100.0030.03517.18
5.5.90.0040.02317.35
5.5.80.0050.03917.32
5.5.70.0040.02417.29
5.5.60.0000.03017.27
5.5.50.0060.02117.26
5.5.40.0070.02317.07
5.5.30.0030.02317.20
5.5.20.0020.02617.04
5.5.10.0080.02017.25
5.5.00.0030.02317.26
5.4.450.0050.02515.72
5.4.440.0020.03415.70
5.4.430.0000.04715.70
5.4.420.0050.04215.58
5.4.410.0040.03115.60
5.4.400.0020.04315.61
5.4.390.0020.03515.51
5.4.380.0030.03315.51
5.4.370.0040.04215.61
5.4.360.0030.02815.56
5.4.350.0050.02715.46
5.4.340.0080.01815.53
5.4.330.0110.00011.98
5.4.320.0050.02215.51
5.4.310.0040.03615.42
5.4.300.0030.02215.51
5.4.290.0030.03115.43
5.4.280.0040.02315.59
5.4.270.0030.02115.55
5.4.260.0050.02115.51
5.4.250.0070.01815.51
5.4.240.0050.01915.59
5.4.230.0040.01915.60
5.4.220.0030.03515.46
5.4.210.0030.02215.55
5.4.200.0050.03415.59
5.4.190.0040.02315.42
5.4.180.0020.02515.51
5.4.170.0050.01815.53
5.4.160.0000.04115.54
5.4.150.0020.02615.49
5.4.140.0050.02014.19
5.4.130.0050.02014.17
5.4.120.0020.02514.22
5.4.110.0030.02514.23
5.4.100.0020.02514.27
5.4.90.0030.01814.18
5.4.80.0050.02014.25
5.4.70.0030.02314.17
5.4.60.0030.01814.26
5.4.50.0030.01814.17
5.4.40.0030.02114.16
5.4.30.0050.02114.23
5.4.20.0020.02014.18
5.4.10.0020.03314.18
5.4.00.0060.01813.95
5.3.290.0030.02413.32
5.3.280.0020.02613.31
5.3.270.0070.02013.30
5.3.260.0040.02413.30
5.3.250.0080.02513.35
5.3.240.0080.01713.38
5.3.230.0060.01913.35
5.3.220.0050.02013.35
5.3.210.0080.01813.28
5.3.200.0040.02213.28
5.3.190.0010.02313.30
5.3.180.0070.02413.37
5.3.170.0020.02313.37
5.3.160.0050.02513.32
5.3.150.0020.02613.34
5.3.140.0040.01913.28
5.3.130.0020.02313.35
5.3.120.0070.02113.34
5.3.110.0040.02213.29
5.3.100.0030.02213.05
5.3.90.0040.02213.05
5.3.80.0060.01813.03
5.3.70.0070.01812.97
5.3.60.0060.01613.08
5.3.50.0050.02113.05
5.3.40.0060.02212.98
5.3.30.0000.02313.00
5.3.20.0050.01812.88
5.3.10.0000.02912.88
5.3.00.0050.03512.83
5.2.170.0030.02712.23
5.2.160.0000.02712.23
5.2.150.0000.02712.23
5.2.140.0000.03012.23
5.2.130.0000.02312.23
5.2.120.0070.04012.23
5.2.110.0000.05312.23
5.2.100.0000.06312.23
5.2.90.0000.04712.23
5.2.80.0000.04012.23
5.2.70.0000.06712.23
5.2.60.0070.06012.23
5.2.50.0100.05312.23
5.2.40.0100.05012.23
5.2.30.0030.06312.23
5.2.20.0030.05712.23
5.2.10.0030.05012.23
5.2.00.0000.06712.23
5.1.60.0030.03712.23
5.1.50.0000.05312.23
5.1.40.0000.04712.23
5.1.30.0070.05312.23
5.1.20.0030.06012.23
5.1.10.0030.03712.23
5.1.00.0100.05012.23
5.0.50.0000.03312.23
5.0.40.0030.04012.23
5.0.30.0030.06312.23
5.0.20.0000.04012.23
5.0.10.0000.03712.23
5.0.00.0100.05712.23
4.4.90.0030.02312.23
4.4.80.0000.03712.23
4.4.70.0000.03312.23
4.4.60.0000.02712.23
4.4.50.0000.03012.23
4.4.40.0000.05712.23
4.4.30.0000.03312.23
4.4.20.0030.03012.23
4.4.10.0000.03312.23
4.4.00.0000.03312.23
4.3.110.0000.03312.23
4.3.100.0070.03012.23
4.3.90.0000.02712.23
4.3.80.0000.05312.23
4.3.70.0070.02712.23
4.3.60.0000.03712.23
4.3.50.0000.03712.23
4.3.40.0000.04712.23
4.3.30.0000.03012.23
4.3.20.0000.03312.23
4.3.10.0000.04012.23
4.3.00.0000.03712.23

preferences:
60.52 ms | 400 KiB | 5 Q