@ 2013-05-30T11:55:31Z <?php
class Element {
$single = null;
$tag = null;
$value= null;
$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 = null;
$value = null;
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;
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
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).
Version System time (s) User time (s) Memory (MiB) 5.4.15 0.023 0.077 19.26 5.4.14 0.013 0.067 16.44 5.4.13 0.020 0.057 16.25 5.4.12 0.017 0.060 16.43 5.4.11 0.023 0.070 16.54 5.4.10 0.030 0.057 16.31 5.4.9 0.027 0.067 16.22 5.4.8 0.030 0.053 16.50 5.4.7 0.023 0.057 16.37 5.4.6 0.033 0.067 16.40 5.4.5 0.033 0.043 16.36 5.4.4 0.020 0.060 16.41 5.4.3 0.023 0.070 16.36 5.4.2 0.033 0.053 16.48 5.4.1 0.037 0.043 16.38 5.4.0 0.023 0.053 15.81 5.3.25 0.020 0.060 14.65 5.3.24 0.033 0.063 14.59 5.3.23 0.020 0.063 14.51 5.3.22 0.027 0.050 14.50 5.3.21 0.020 0.067 14.54 5.3.20 0.040 0.073 14.63 5.3.19 0.017 0.077 14.49 5.3.18 0.013 0.073 14.65 5.3.17 0.037 0.057 14.67 5.3.16 0.037 0.047 14.61 5.3.15 0.040 0.060 14.47 5.3.14 0.027 0.063 14.54 5.3.13 0.027 0.077 14.52 5.3.12 0.037 0.050 14.50 5.3.11 0.040 0.047 14.62 5.3.10 0.033 0.053 14.10 5.3.9 0.023 0.073 13.88 5.3.8 0.030 0.063 13.99 5.3.7 0.040 0.057 13.99 5.3.6 0.033 0.067 14.02 5.3.5 0.030 0.050 13.99 5.3.4 0.037 0.063 13.95 5.3.3 0.020 0.073 13.80 5.3.2 0.023 0.070 13.64 5.3.1 0.020 0.063 13.64 5.3.0 0.023 0.057 13.57
preferences:dark mode live preview
145.04 ms | 1398 KiB | 7 Q