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.'>'); } } const NewLine = "<br />"; const 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.40.0070.00718.71
8.3.30.0110.00719.10
8.3.20.0070.00720.30
8.3.10.0040.00422.04
8.3.00.0000.00822.36
8.2.170.0040.01122.96
8.2.160.0070.00720.93
8.2.150.0030.00524.18
8.2.140.0000.00924.66
8.2.130.0040.00426.16
8.2.120.0080.00019.23
8.2.110.0100.00020.47
8.2.100.0080.00317.72
8.2.90.0080.00019.08
8.2.80.0050.00317.97
8.2.70.0040.00417.38
8.2.60.0050.00317.80
8.2.50.0000.01418.10
8.2.40.0040.00418.22
8.2.30.0030.00618.08
8.2.20.0000.00817.79
8.2.10.0050.00317.75
8.2.00.0000.00817.73
8.1.270.0050.00322.32
8.1.260.0040.00426.35
8.1.250.0070.01128.09
8.1.240.0030.00721.38
8.1.230.0080.00317.89
8.1.220.0050.00317.74
8.1.210.0040.00418.77
8.1.200.0030.00617.35
8.1.190.0040.00417.23
8.1.180.0060.00318.10
8.1.170.0040.00618.65
8.1.160.0040.00422.10
8.1.150.0030.00518.56
8.1.140.0070.00017.45
8.1.130.0070.00017.77
8.1.120.0070.00017.37
8.1.110.0080.00017.36
8.1.100.0090.00017.47
8.1.90.0000.00817.36
8.1.80.0070.00017.50
8.1.70.0000.00717.36
8.1.60.0000.00817.58
8.1.50.0000.00817.53
8.1.40.0040.00417.43
8.1.30.0040.00417.48
8.1.20.0030.00617.66
8.1.10.0000.00917.44
8.1.00.0040.00417.44
8.0.300.0040.00418.77
8.0.290.0080.00016.75
8.0.280.0000.00818.36
8.0.270.0000.00717.38
8.0.260.0070.00016.85
8.0.250.0050.00216.94
8.0.240.0000.00816.90
8.0.230.0000.00717.01
8.0.220.0040.00416.84
8.0.210.0030.00316.95
8.0.200.0060.00016.89
8.0.190.0000.00917.01
8.0.180.0040.00416.89
8.0.170.0030.00517.00
8.0.160.0000.00716.88
8.0.150.0070.00016.87
8.0.140.0040.00416.97
8.0.130.0030.00313.43
8.0.120.0000.00816.88
8.0.110.0000.00816.87
8.0.100.0070.00016.98
8.0.90.0040.00416.86
8.0.80.0060.00916.85
8.0.70.0000.00816.95
8.0.60.0040.00416.95
8.0.50.0040.00416.98
8.0.30.0140.00617.05
8.0.20.0160.00417.40
8.0.10.0000.00717.15
8.0.00.0080.01316.68
7.4.330.0000.00515.10
7.4.320.0000.00716.50
7.4.300.0000.00616.43
7.4.290.0030.00316.57
7.4.280.0040.00416.71
7.4.270.0000.00716.58
7.4.260.0000.00716.67
7.4.250.0000.00816.61
7.4.240.0040.00416.54
7.4.230.0080.00016.70
7.4.220.0070.01616.62
7.4.210.0070.00916.67
7.4.200.0000.00716.64
7.4.190.0000.00816.74
7.4.160.0150.00016.60
7.4.150.0140.00417.40
7.4.140.0080.00917.86
7.4.130.0090.00716.59
7.4.120.0070.00916.48
7.4.110.0100.00716.63
7.4.100.0070.01016.68
7.4.90.0090.00916.49
7.4.80.0070.01016.59
7.4.70.0160.00316.54
7.4.60.0160.00016.57
7.4.50.0000.00716.75
7.4.40.0100.00622.77
7.4.30.0090.00916.48
7.4.00.0000.01715.01
7.3.330.0030.00313.37
7.3.320.0030.00313.42
7.3.310.0000.00816.29
7.3.300.0040.00416.30
7.3.290.0070.01016.33
7.3.280.0080.00916.41
7.3.270.0080.00817.40
7.3.260.0100.00716.39
7.3.250.0100.00816.50
7.3.240.0090.01216.38
7.3.230.0130.00316.46
7.3.210.0090.01216.35
7.3.200.0150.00619.39
7.3.190.0120.00916.39
7.3.180.0080.00816.61
7.3.170.0040.01416.59
7.3.160.0070.01416.74
7.3.120.0100.00714.66
7.3.00.0120.00616.72
7.2.330.0060.01116.73
7.2.320.0120.00816.86
7.2.310.0120.00616.91
7.2.300.0120.00416.57
7.2.290.0090.01616.65
7.2.130.0120.00616.70
7.2.120.0170.00017.04
7.2.110.0100.00317.01
7.2.100.0040.01116.80
7.2.90.0060.01217.17
7.2.80.0070.01017.04
7.2.70.0130.00317.19
7.2.60.0080.01117.02
7.2.50.0060.00316.70
7.2.40.0090.00617.02
7.2.30.0120.00917.02
7.2.20.0090.01416.96
7.2.10.0130.01617.03
7.2.00.0060.01016.54
7.1.250.0100.01015.95
7.1.240.0120.00315.57
7.1.230.0120.00315.78
7.1.220.0130.00015.80
7.1.210.0060.00915.48
7.1.200.0060.01215.75
7.1.190.0040.00715.81
7.1.180.0200.00015.40
7.1.170.0060.00615.61
7.1.160.0030.01115.82
7.1.150.0080.00815.97
7.1.140.0080.01615.77
7.1.130.0150.00515.71
7.1.120.0180.00415.55
7.1.110.0110.00715.81
7.1.100.0120.01515.70
7.1.90.0040.01115.73
7.1.80.0060.00915.69
7.1.70.0020.00916.62
7.1.60.0100.01017.86
7.1.50.0070.01016.20
7.1.40.0000.01315.84
7.1.30.0060.00615.77
7.1.20.0000.01115.81
7.1.10.0040.01115.61
7.1.00.0050.03819.04
7.0.330.0030.01015.10
7.0.320.0090.00615.59
7.0.310.0030.00615.43
7.0.300.0050.00515.35
7.0.290.0070.00715.48
7.0.280.0160.00615.32
7.0.270.0170.00815.13
7.0.260.0110.01915.34
7.0.250.0140.01415.37
7.0.240.0090.01115.33
7.0.230.0030.00915.60
7.0.220.0040.00815.27
7.0.210.0070.00715.51
7.0.200.0100.00615.07
7.0.190.0070.00715.41
7.0.180.0070.00715.47
7.0.170.0060.00615.45
7.0.160.0090.00315.50
7.0.150.0040.00715.34
7.0.140.0020.04318.72
7.0.130.0070.00315.32
7.0.120.0120.00315.36
7.0.110.0070.00715.45
7.0.100.0040.00815.47
7.0.90.0090.00615.25
7.0.80.0370.04517.68
7.0.70.0300.04317.67
7.0.60.0150.02617.55
7.0.50.0320.04217.96
7.0.40.0070.03316.90
7.0.30.0000.05416.66
7.0.20.0050.02716.68
7.0.10.0050.02216.77
7.0.00.0040.04016.68
5.6.380.0030.00714.52
5.6.370.0090.00614.23
5.6.360.0040.01214.62
5.6.350.0100.00314.75
5.6.340.0070.00714.83
5.6.330.0030.01114.52
5.6.320.0120.00314.89
5.6.310.0040.01114.61
5.6.300.0040.00914.50
5.6.290.0070.00714.71
5.6.280.0050.04017.93
5.6.270.0120.00314.69
5.6.260.0100.00314.72
5.6.250.0060.00914.80
5.6.240.0000.01714.18
5.6.230.0030.02717.47
5.6.220.0080.04217.62
5.6.210.0070.02417.59
5.6.200.0100.04217.79
5.6.190.0070.04317.66
5.6.180.0030.04317.71
5.6.170.0140.03117.75
5.6.160.0030.04617.82
5.6.150.0070.04217.86
5.6.140.0070.04217.76
5.6.130.0080.02318.06
5.6.120.0020.02817.88
5.6.110.0080.03417.86
5.6.100.0110.02817.94
5.6.90.0030.04817.80
5.6.80.0080.04317.42
5.6.70.0150.02417.46
5.6.60.0070.02717.39
5.6.50.0120.04317.52
5.6.40.0070.02817.39
5.6.30.0070.02817.32
5.6.20.0090.02717.45
5.6.10.0060.02317.32
5.6.00.0020.03817.60
5.5.380.0040.00411.42
5.5.370.0090.04215.91
5.5.360.0080.04315.87
5.5.350.0100.02615.82
5.5.340.0070.03516.20
5.5.330.0080.04115.97
5.5.320.0100.02516.13
5.5.310.0060.02816.13
5.5.300.0020.02716.12
5.5.290.0050.02616.14
5.5.280.0070.02216.06
5.5.270.0070.04216.25
5.5.260.0070.04316.01
5.5.250.0020.03516.09
5.5.240.0050.03215.58
5.5.230.0050.04015.79
5.5.220.0080.02515.62
5.5.210.0050.04315.83
5.5.200.0080.03515.84
5.5.190.0050.04415.72
5.5.180.0050.02215.72
5.5.170.0030.00911.41
5.5.160.0120.03815.72
5.5.150.0070.04015.76
5.5.140.0110.03815.72
5.5.130.0060.02615.92
5.5.120.0080.02015.81
5.5.110.0060.04015.76
5.5.100.0090.03815.82
5.5.90.0090.04015.67
5.5.80.0030.04415.65
5.5.70.0100.03715.80
5.5.60.0070.03915.75
5.5.50.0030.03015.73
5.5.40.0120.03515.75
5.5.30.0100.03315.79
5.5.20.0060.04715.84
5.5.10.0050.04415.62
5.5.00.0050.04715.70
5.4.450.0060.02015.35
5.4.440.0100.04015.32
5.4.430.0080.03915.26
5.4.420.0050.04215.36
5.4.410.0020.03015.31
5.4.400.0030.04115.16
5.4.390.0070.02315.09
5.4.380.0070.02515.22
5.4.370.0020.03715.05
5.4.360.0070.04015.10
5.4.350.0080.03715.13
5.4.340.0080.03515.13
5.4.330.0040.01111.28
5.4.320.0050.02515.22
5.4.310.0040.02915.05
5.4.300.0090.02815.19
5.4.290.0080.04015.01
5.4.280.0030.02415.09
5.4.270.0080.02714.96
5.4.260.0050.04314.95
5.4.250.0130.03515.18
5.4.240.0030.03415.01
5.4.230.0090.04215.08
5.4.220.0090.03815.13
5.4.210.0040.02615.19
5.4.200.0080.02615.20
5.4.190.0040.02415.06
5.4.180.0090.03915.10
5.4.170.0050.03115.26
5.4.160.0040.04415.30
5.4.150.0040.05215.06
5.4.140.0110.03113.72
5.4.130.0080.03613.69
5.4.120.0040.04213.85
5.4.110.0050.03013.66
5.4.100.0030.02413.67
5.4.90.0000.03113.79
5.4.80.0050.04113.80
5.4.70.0050.03013.81
5.4.60.0020.04113.83
5.4.50.0100.02313.64
5.4.40.0120.02513.80
5.4.30.0060.02213.81
5.4.20.0140.03013.88
5.4.10.0060.02513.71
5.4.00.0050.03313.61
5.3.290.0010.02812.68
5.3.280.0060.02612.72
5.3.270.0020.03412.72
5.3.260.0100.03812.57
5.3.250.0070.04312.76
5.3.240.0050.02412.58
5.3.230.0050.02412.70
5.3.220.0060.02512.61
5.3.210.0030.04512.57
5.3.200.0040.03412.43
5.3.190.0090.03512.53
5.3.180.0060.04012.57
5.3.170.0040.04112.73
5.3.160.0030.02512.69
5.3.150.0030.03212.75
5.3.140.0060.03812.58
5.3.130.0050.02612.73
5.3.120.0030.02712.67
5.3.110.0090.02712.53
5.3.100.0070.02312.40
5.3.90.0020.03312.45
5.3.80.0070.02012.38
5.3.70.0100.01312.28
5.3.60.0020.02512.43
5.3.50.0000.02612.29
5.3.40.0040.04412.23
5.3.30.0080.02212.15
5.3.20.0020.02312.12
5.3.10.0070.02311.97
5.3.00.0070.03312.07
5.2.170.0090.02811.76
5.2.160.0020.01911.76
5.2.150.0070.02711.76
5.2.140.0030.02311.76
5.2.130.0080.02311.76
5.2.120.0030.03511.76
5.2.110.0020.02111.76
5.2.100.0070.01711.76
5.2.90.0020.02211.76
5.2.80.0020.01811.76
5.2.70.0040.02911.76
5.2.60.0070.03211.76
5.2.50.0030.02411.76
5.2.40.0030.02911.76
5.2.30.0020.01811.76
5.2.20.0000.02111.76
5.2.10.0070.03011.76
5.2.00.0050.03211.76
5.1.60.0000.02911.76
5.1.50.0020.03111.76
5.1.40.0060.02811.76
5.1.30.0040.02411.76
5.1.20.0030.01711.76
5.1.10.0070.02311.76
5.1.00.0040.02111.76
5.0.50.0030.02311.76
5.0.40.0060.01311.76
5.0.30.0060.02711.76
5.0.20.0040.01311.76
5.0.10.0050.01311.76
5.0.00.0060.03311.76
4.4.90.0030.02111.76
4.4.80.0050.01311.76
4.4.70.0000.01111.76
4.4.60.0020.01911.76
4.4.50.0030.01511.76
4.4.40.0080.01511.76
4.4.30.0020.01511.76
4.4.20.0020.02011.76
4.4.10.0020.01611.76
4.4.00.0050.02211.76
4.3.110.0020.02011.76
4.3.100.0030.01211.76
4.3.90.0020.01311.76
4.3.80.0050.01711.76
4.3.70.0060.01611.76
4.3.60.0030.01111.76
4.3.50.0000.02411.76
4.3.40.0030.02711.76
4.3.30.0050.01311.76
4.3.20.0020.01411.76
4.3.10.0030.02011.76
4.3.00.0010.01411.76

preferences:
34.26 ms | 400 KiB | 5 Q