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])-1); } var_dump($as); array_push($newlist, new Attribute($as[0], $as[1])); } var_dump($newlist); 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.0070.01416.88
8.3.50.0130.01017.48
8.3.40.0060.01318.79
8.3.30.0180.00418.54
8.3.20.0060.00318.78
8.3.10.0080.00020.32
8.3.00.0000.00819.18
8.2.180.0100.00716.50
8.2.170.0070.00722.96
8.2.160.0100.00320.97
8.2.150.0040.00424.18
8.2.140.0110.00424.66
8.2.130.0120.00326.16
8.2.120.0040.00419.23
8.2.110.0070.00321.10
8.2.100.0040.00717.59
8.2.90.0030.00619.30
8.2.80.0040.00418.03
8.2.70.0030.00617.63
8.2.60.0080.00317.80
8.2.50.0000.00818.07
8.2.40.0040.00418.22
8.2.30.0030.00618.07
8.2.20.0000.00817.75
8.2.10.0080.00017.80
8.2.00.0040.00417.78
8.1.280.0070.01525.92
8.1.270.0040.00423.99
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0070.00320.91
8.1.230.0120.00021.10
8.1.220.0060.00317.79
8.1.210.0030.00518.79
8.1.200.0030.00717.35
8.1.190.0000.00917.65
8.1.180.0070.00318.10
8.1.170.0080.00019.03
8.1.160.0040.00418.95
8.1.150.0040.00418.61
8.1.140.0080.00017.35
8.1.130.0030.00317.88
8.1.120.0040.00417.52
8.1.110.0000.00917.37
8.1.100.0040.00417.44
8.1.90.0020.00517.36
8.1.80.0040.00417.43
8.1.70.0070.00017.48
8.1.60.0000.00817.63
8.1.50.0000.00917.50
8.1.40.0060.00317.57
8.1.30.0030.00517.61
8.1.20.0040.00417.56
8.1.10.0000.00817.47
8.1.00.0040.00417.39
8.0.300.0040.00420.02
8.0.290.0050.00216.75
8.0.280.0040.00418.47
8.0.270.0050.00317.20
8.0.260.0030.00316.96
8.0.250.0040.00416.98
8.0.240.0000.00716.91
8.0.230.0030.00316.95
8.0.220.0000.00716.87
8.0.210.0000.00716.96
8.0.200.0000.00717.04
8.0.190.0030.00517.09
8.0.180.0070.00016.89
8.0.170.0100.00016.93
8.0.160.0040.00316.92
8.0.150.0080.00016.80
8.0.140.0050.00317.00
8.0.130.0000.00713.38
8.0.120.0060.00316.99
8.0.110.0050.00216.86
8.0.100.0000.00716.79
8.0.90.0000.00717.02
8.0.80.0100.00716.95
8.0.70.0000.00716.85
8.0.60.0000.00716.91
8.0.50.0000.00817.02
8.0.30.0130.01017.24
8.0.20.0070.01117.07
8.0.10.0060.00316.96
8.0.00.0110.00816.68
7.4.330.0060.00013.05
7.4.320.0000.00616.68
7.4.300.0040.00416.59
7.4.290.0030.00316.59
7.4.280.0040.00416.69
7.4.270.0040.00416.59
7.4.260.0030.00413.40
7.4.250.0000.00816.58
7.4.240.0030.00316.62
7.4.230.0040.00416.56
7.4.220.0030.01716.71
7.4.210.0050.01116.67
7.4.200.0020.00716.38
7.4.190.0000.00816.44
7.4.160.0070.01016.60
7.4.150.0110.00816.56
7.4.140.0130.01616.67
7.4.130.0090.01116.62
7.4.120.0170.00216.53
7.4.110.0090.00816.75
7.4.100.0100.01016.53
7.4.90.0070.01116.69
7.4.80.0110.01119.39
7.4.70.0030.01516.61
7.4.60.0030.01616.60
7.4.50.0070.00316.43
7.4.40.0000.01116.72
7.4.30.0090.00916.62
7.4.10.0000.01715.12
7.4.00.0070.01114.84
7.3.330.0070.00013.30
7.3.320.0080.00013.28
7.3.310.0040.00416.42
7.3.300.0030.00316.30
7.3.290.0060.00916.38
7.3.280.0080.00816.49
7.3.270.0040.01516.37
7.3.260.0130.01116.55
7.3.250.0070.01516.52
7.3.240.0040.01316.44
7.3.230.0100.01416.39
7.3.210.0150.00316.67
7.3.200.0060.01216.66
7.3.190.0160.00816.47
7.3.180.0120.00616.61
7.3.170.0090.00916.61
7.3.160.0150.00416.58
7.3.130.0100.01015.00
7.3.120.0060.00914.81
7.3.110.0030.01314.93
7.3.100.0080.00615.07
7.3.90.0110.00514.80
7.3.80.0050.00814.79
7.3.70.0030.01115.03
7.3.60.0080.00714.88
7.3.50.0050.00714.88
7.3.40.0030.00914.87
7.3.30.0080.00814.90
7.3.20.0050.00916.66
7.3.10.0080.00616.52
7.3.00.0070.00816.89
7.2.330.0120.00916.53
7.2.320.0120.00616.52
7.2.310.0060.01516.76
7.2.300.0070.01016.86
7.2.290.0090.01216.71
7.2.260.0030.01115.06
7.2.250.0090.01015.22
7.2.240.0050.01515.24
7.2.230.0020.01215.15
7.2.220.0090.00414.86
7.2.210.0110.00515.19
7.2.200.0040.00814.99
7.2.190.0060.00815.20
7.2.180.0040.01215.11
7.2.170.0050.00815.17
7.2.160.0030.01215.07
7.2.150.0050.00516.57
7.2.140.0000.01416.84
7.2.130.0070.01116.77
7.2.120.0070.00616.74
7.2.110.0070.00816.94
7.2.100.0030.01116.74
7.2.90.0070.00916.95
7.2.80.0060.00516.85
7.2.70.0050.00817.09
7.2.60.0120.00217.00
7.2.50.0020.01216.96
7.2.40.0080.00516.84
7.2.30.0110.00516.96
7.2.20.0050.00716.90
7.2.10.0050.00917.07
7.2.00.0070.00517.74
7.1.330.0030.01015.83
7.1.320.0050.00915.77
7.1.310.0040.01115.94
7.1.300.0050.00915.89
7.1.290.0070.00715.83
7.1.280.0080.00715.87
7.1.270.0080.00415.78
7.1.260.0060.01015.91
7.1.250.0060.00815.77
7.1.240.0040.01015.81
7.1.230.0020.00815.78
7.1.220.0070.00615.83
7.1.210.0070.00315.86
7.1.200.0070.00515.86
7.1.190.0080.00415.81
7.1.180.0030.01015.93
7.1.170.0050.00615.85
7.1.160.0030.00915.93
7.1.150.0020.01315.80
7.1.140.0090.00415.59
7.1.130.0060.00515.91
7.1.120.0020.01315.79
7.1.110.0030.01015.77
7.1.100.0340.00514.70
7.1.90.0080.00415.76
7.1.80.0030.01015.80
7.1.70.0080.00416.18
7.1.60.0050.01216.90
7.1.50.0080.00716.22
7.1.40.0040.00915.79
7.1.30.0030.00915.68
7.1.20.0040.00715.71
7.1.10.0040.00815.83
7.1.00.0060.03118.07
7.0.330.0000.01315.48
7.0.320.0060.00515.52
7.0.310.0070.00615.33
7.0.300.0070.00415.35
7.0.290.0110.00215.47
7.0.280.0050.00415.29
7.0.270.0070.00715.32
7.0.260.0010.01315.44
7.0.250.0020.01115.57
7.0.240.0060.00515.53
7.0.230.0060.00615.46
7.0.220.0060.00615.56
7.0.210.0040.00915.38
7.0.200.0100.01115.28
7.0.190.0050.00915.59
7.0.180.0050.00815.55
7.0.170.0050.01015.43
7.0.160.0070.00815.60
7.0.150.0030.00715.44
7.0.140.0070.02817.67
7.0.130.0030.00915.55
7.0.120.0070.02817.63
7.0.110.0030.00815.52
7.0.100.0140.02717.06
7.0.90.0230.02717.02
7.0.80.0160.02916.95
7.0.70.0100.02517.05
7.0.60.0150.03416.91
7.0.50.0170.02717.18
7.0.40.0100.02515.73
7.0.30.0100.03515.62
7.0.20.0060.02315.73
7.0.10.0060.03715.62
7.0.00.0040.02415.71
5.6.400.0070.01114.50
5.6.390.0060.01314.25
5.6.380.0050.00914.76
5.6.370.0030.01114.61
5.6.360.0020.01314.45
5.6.350.0030.00814.51
5.6.340.0070.00814.77
5.6.330.0060.00914.54
5.6.320.0100.00214.49
5.6.310.0040.01014.77
5.6.300.0090.00414.76
5.6.290.0060.00814.32
5.6.280.0050.03016.68
5.6.270.0060.00614.63
5.6.260.0060.00714.90
5.6.250.0070.03216.57
5.6.240.0060.03516.76
5.6.230.0060.02416.57
5.6.220.0060.03016.68
5.6.210.0110.02616.45
5.6.200.0080.03416.87
5.6.190.0080.03216.93
5.6.180.0090.02816.78
5.6.170.0100.03116.54
5.6.160.0080.02916.83
5.6.150.0080.03316.70
5.6.140.0040.02316.77
5.6.130.0090.03216.80
5.6.120.0070.03416.71
5.6.110.0070.03016.66
5.6.100.0040.03416.77
5.6.90.0040.02816.65
5.6.80.0080.02316.47
5.6.70.0090.02816.32
5.6.60.0100.03016.43
5.6.50.0100.02416.50
5.6.40.0070.02716.50
5.6.30.0050.03316.50
5.6.20.0090.03016.38
5.6.10.0060.03316.40
5.6.00.0080.02916.49
5.5.380.0070.02815.46
5.5.370.0060.02615.42
5.5.360.0060.03115.55
5.5.350.0020.03315.37
5.5.340.0080.02915.42
5.5.330.0110.02515.59
5.5.320.0090.02815.61
5.5.310.0060.01715.44
5.5.300.0040.02615.57
5.5.290.0070.02715.54
5.5.280.0080.01715.55
5.5.270.0050.01915.57
5.5.260.0050.03415.58
5.5.250.0050.03215.36
5.5.240.0050.02215.35
5.5.230.0080.02715.34
5.5.220.0080.02815.38
5.5.210.0090.03015.30
5.5.200.0060.02115.23
5.5.190.0030.03315.39
5.5.180.0060.03115.28
5.5.170.0060.00814.38
5.5.160.0070.03215.39
5.5.150.0100.01815.27
5.5.140.0030.03315.46
5.5.130.0060.03115.43
5.5.120.0070.03015.20
5.5.110.0030.03415.31
5.5.100.0080.03115.32
5.5.90.0050.03215.31
5.5.80.0070.03015.12
5.5.70.0050.03215.20
5.5.60.0060.03315.21
5.5.50.0020.02815.11
5.5.40.0040.03415.33
5.5.30.0090.03115.20
5.5.20.0060.03215.21
5.5.10.0100.02915.18
5.5.00.0060.03215.30
5.4.450.0110.02414.17
5.4.440.0100.02713.88
5.4.430.0100.02813.91
5.4.420.0070.02814.04
5.4.410.0050.01713.92
5.4.400.0060.03013.86
5.4.390.0060.03113.77
5.4.380.0080.02713.79
5.4.370.0060.03013.77
5.4.360.0090.02613.79
5.4.350.0080.02713.89
5.4.340.0070.02913.77
5.4.330.0050.00811.28
5.4.320.0070.03313.84
5.4.310.0080.02913.78
5.4.300.0050.03013.74
5.4.290.0080.03113.80
5.4.280.0070.02013.83
5.4.270.0070.02813.86
5.4.260.0110.02313.81
5.4.250.0100.02413.78
5.4.240.0070.02013.89
5.4.230.0090.02913.93
5.4.220.0100.02813.83
5.4.210.0110.02513.79
5.4.200.0060.02413.81
5.4.190.0040.03213.97
5.4.180.0090.02613.69
5.4.170.0080.03213.83
5.4.160.0090.02013.85
5.4.150.0110.02813.77
5.4.140.0040.03012.95
5.4.130.0080.02712.95
5.4.120.0070.02912.95
5.4.110.0080.02913.04
5.4.100.0080.02612.98
5.4.90.0100.02713.04
5.4.80.0050.02912.98
5.4.70.0070.02413.05
5.4.60.0070.02912.97
5.4.50.0070.02712.83
5.4.40.0040.02913.01
5.4.30.0050.02112.90
5.4.20.0060.02712.88
5.4.10.0070.02813.08
5.4.00.0090.02412.84
5.3.290.0060.02812.40
5.3.280.0060.02512.38
5.3.270.0120.02312.40
5.3.260.0030.03012.47
5.3.250.0080.02512.40
5.3.240.0090.02812.45
5.3.230.0060.02812.40
5.3.220.0040.01812.39
5.3.210.0040.02112.45
5.3.200.0090.02412.34
5.3.190.0080.01712.47
5.3.180.0080.02212.50
5.3.170.0040.03012.40
5.3.160.0060.01712.54
5.3.150.0080.02412.51
5.3.140.0050.03212.47
5.3.130.0060.03012.40
5.3.120.0100.01612.47
5.3.110.0100.02612.49
5.3.100.0050.02712.38
5.3.90.0060.01912.40
5.3.80.0100.01512.38
5.3.70.0100.02212.44
5.3.60.0060.02512.47
5.3.50.0040.02712.39
5.3.40.0090.02612.44
5.3.30.0090.01812.39
5.3.20.0080.02312.39
5.3.10.0080.02612.39
5.3.00.0090.02212.32

preferences:
39.2 ms | 401 KiB | 5 Q