Skip to content
Permalink
d5d32d9639
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
29 lines (21 sloc) 488 Bytes
<?php
class Element {
public $tag;
public $content;
public $attrs;
public function __construct($t, $c, $a = []) {
$this->tag = $t;
$this->content = $c;
$this->attrs = $a;
}
public function setAttribute($name, $value) {
$this->attrs[$name] = $value;
}
public function __toString() {
$attr_string = '';
foreach($this->attrs as $name => $value) {
$attr_string .= "{$name}='{$value}' ";
}
return "<$this->tag $attr_string>$this->content</$this->tag>";
}
}