HtmlElement
in package
Table of Contents
- $attributes : array<string|int, string>
- $contents : HtmlElement|array<string|int, HtmlElement>|string
- $selfClosing : bool
- $tagName : string
- __construct() : mixed
- __toString() : string
- getAllAttributes() : array<string|int, string>
- getAttribute() : string|null
- getContents() : HtmlElement|array<string|int, HtmlElement>|string
- getTagName() : string
- setAttribute() : self
- setContents() : $this
- Sets the inner contents of the tag (must be pre-escaped if needed)
- getContentsAsString() : string
Properties
$attributes
protected
array<string|int, string>
$attributes
= []
$contents
protected
HtmlElement|array<string|int, HtmlElement>|string
$contents
$selfClosing
protected
bool
$selfClosing
= false
$tagName
protected
string
$tagName
Methods
__construct()
public
__construct(string $tagName[, array<string|int, string> $attributes = [] ][, HtmlElement|array<string|int, HtmlElement>|string|null $contents = '' ][, bool $selfClosing = false ]) : mixed
Parameters
- $tagName : string
-
Name of the HTML tag
- $attributes : array<string|int, string> = []
-
Array of attributes (values should be unescaped)
- $contents : HtmlElement|array<string|int, HtmlElement>|string|null = ''
-
Inner contents, pre-escaped if needed
- $selfClosing : bool = false
-
Whether the tag is self-closing
Return values
mixed —__toString()
public
__toString() : string
Return values
string —getAllAttributes()
public
getAllAttributes() : array<string|int, string>
Return values
array<string|int, string> —getAttribute()
public
getAttribute(string $key) : string|null
Parameters
- $key : string
Return values
string|null —getContents()
public
getContents([bool $asString = true ]) : HtmlElement|array<string|int, HtmlElement>|string
Parameters
- $asString : bool = true
Return values
HtmlElement|array<string|int, HtmlElement>|string —getTagName()
public
getTagName() : string
Return values
string —setAttribute()
public
setAttribute(string $key, string $value) : self
Parameters
- $key : string
- $value : string
Return values
self —setContents()
Sets the inner contents of the tag (must be pre-escaped if needed)
public
setContents(HtmlElement|array<string|int, HtmlElement>|string $contents) : $this
Parameters
- $contents : HtmlElement|array<string|int, HtmlElement>|string
Return values
$this —getContentsAsString()
private
getContentsAsString() : string