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