3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Element { $single, $tag, $value, $attr=array(); function __construct($tag, $single = false) { $this->tag = $tag; $this->single = $single; } function Value($value) { $this->value = $value; } function AddAttr($attr, $list = false) { if ($list) { $this->attr = array_merge($this->attr, $list); } else { array_push($this->attr, $attr); } } 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(""); } } 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)); } } 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])-2); } array_push($newlist, new Attribute($as[0], $as[1])); } $this->attr = array_merge($this->attr, $newlist); } 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]); } } } } 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 { $name, $value; function __construct($name, $value = "") { $this->name = $name; $this->value = $value; } function Name($name = null) { if ($name === null) { return $this->name; } else { $this->name = $name; } } function Value($value = null) { if ($value === null) { return $this->value; } else { $this->value = $value; } } 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)
5.4.150.0210.05612.36
5.4.140.0260.06312.05
5.4.130.0190.07012.03
5.4.120.0240.06412.00
5.4.110.0190.06911.99
5.4.100.0150.04311.99
5.4.90.0200.06811.99
5.4.80.0210.06711.99
5.4.70.0300.07611.99
5.4.60.0210.05211.99
5.4.50.0130.04611.99
5.4.40.0210.06711.97
5.4.30.0150.06011.97
5.4.20.0260.06411.97
5.4.10.0290.05811.97
5.4.00.0120.04411.47
5.3.250.0220.07512.72
5.3.240.0160.04312.72
5.3.230.0300.09612.71
5.3.220.0190.04212.68
5.3.210.0190.07412.68
5.3.200.0230.06112.68
5.3.190.0230.07212.68
5.3.180.0330.07312.67
5.3.170.0230.06512.67
5.3.160.0290.06512.67
5.3.150.0250.06712.67
5.3.140.0250.06512.66
5.3.130.0260.08312.66
5.3.120.0240.06512.66
5.3.110.0170.04312.66
5.3.100.0150.04612.12
5.3.90.0200.05312.08
5.3.80.0250.09412.08
5.3.70.0290.06112.07
5.3.60.0140.05212.06
5.3.50.0220.06812.00
5.3.40.0250.06312.01
5.3.30.0140.05911.96
5.3.20.0310.06111.74
5.3.10.0180.03911.70
5.3.00.0120.04611.69

preferences:
133.73 ms | 1399 KiB | 7 Q