public toString ( boolean $attributes = true, boolean | integer $recursive = true, boolean | integer $content_only = false ) : string | ||
$attributes | boolean | Print attributes (of child tags) |
$recursive | boolean | integer | How many sub-levels of child tags to print. True for all. |
$content_only | boolean | integer | Only print text, false will print tags too. |
리턴 | string |
function toString($attributes = true, $recursive = true, $content_only = false)
{
if ($content_only) {
if (is_int($content_only)) {
--$content_only;
}
return $this->toString_content($attributes, $recursive, $content_only);
}
$s = '<' . $this->tag;
if ($attributes) {
$s .= $this->toString_attributes();
}
if ($this->self_close) {
$s .= $this->self_close_str . '>';
} else {
$s .= '>';
if ($recursive) {
$s .= $this->toString_content($attributes);
}
$s .= '</' . $this->tag . '>';
}
return $s;
}