@ 2013-05-30T11:54:59Z <?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;
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.021 0.056 12.36 5.4.14 0.026 0.063 12.05 5.4.13 0.019 0.070 12.03 5.4.12 0.024 0.064 12.00 5.4.11 0.019 0.069 11.99 5.4.10 0.015 0.043 11.99 5.4.9 0.020 0.068 11.99 5.4.8 0.021 0.067 11.99 5.4.7 0.030 0.076 11.99 5.4.6 0.021 0.052 11.99 5.4.5 0.013 0.046 11.99 5.4.4 0.021 0.067 11.97 5.4.3 0.015 0.060 11.97 5.4.2 0.026 0.064 11.97 5.4.1 0.029 0.058 11.97 5.4.0 0.012 0.044 11.47 5.3.25 0.022 0.075 12.72 5.3.24 0.016 0.043 12.72 5.3.23 0.030 0.096 12.71 5.3.22 0.019 0.042 12.68 5.3.21 0.019 0.074 12.68 5.3.20 0.023 0.061 12.68 5.3.19 0.023 0.072 12.68 5.3.18 0.033 0.073 12.67 5.3.17 0.023 0.065 12.67 5.3.16 0.029 0.065 12.67 5.3.15 0.025 0.067 12.67 5.3.14 0.025 0.065 12.66 5.3.13 0.026 0.083 12.66 5.3.12 0.024 0.065 12.66 5.3.11 0.017 0.043 12.66 5.3.10 0.015 0.046 12.12 5.3.9 0.020 0.053 12.08 5.3.8 0.025 0.094 12.08 5.3.7 0.029 0.061 12.07 5.3.6 0.014 0.052 12.06 5.3.5 0.022 0.068 12.00 5.3.4 0.025 0.063 12.01 5.3.3 0.014 0.059 11.96 5.3.2 0.031 0.061 11.74 5.3.1 0.018 0.039 11.70 5.3.0 0.012 0.046 11.69
preferences:dark mode live preview
133.73 ms | 1399 KiB | 7 Q