Html
class Html implements ArrayAccess, Countable, IteratorAggregate, HtmlStringable
HTML helper.
Properties
array<string,mixed> | $attrs | ||
static bool | $xhtml | ||
static array<string,int> | $emptyElements | ||
protected HtmlStringable|string> | $children | ||
string|null | $accept | ||
string|null | $accesskey | ||
string|null | $action | ||
string|null | $align | ||
string|null | $allow | ||
string|null | $alt | ||
bool|null | $async | ||
string|null | $autocapitalize | ||
string|null | $autocomplete | ||
bool|null | $autofocus | ||
bool|null | $autoplay | ||
string|null | $charset | ||
bool|null | $checked | ||
string|null | $cite | ||
string|null | $class | ||
int|null | $cols | ||
int|null | $colspan | ||
string|null | $content | ||
bool|null | $contenteditable | ||
bool|null | $controls | ||
string|null | $coords | ||
string|null | $crossorigin | ||
string|null | $data | ||
string|null | $datetime | ||
string|null | $decoding | ||
bool|null | $default | ||
bool|null | $defer | ||
string|null | $dir | ||
string|null | $dirname | ||
bool|null | $disabled | ||
bool|null | $download | ||
string|null | $draggable | ||
string|null | $dropzone | ||
string|null | $enctype | ||
string|null | $for | ||
string|null | $form | ||
string|null | $formaction | ||
string|null | $formenctype | ||
string|null | $formmethod | ||
bool|null | $formnovalidate | ||
string|null | $formtarget | ||
string|null | $headers | ||
int|null | $height | ||
$hidden | |||
float|null | $high | ||
string|null | $href | ||
string|null | $hreflang | ||
string|null | $id | ||
string|null | $integrity | ||
string|null | $inputmode | ||
bool|null | $ismap | ||
string|null | $itemprop | ||
string|null | $kind | ||
string|null | $label | ||
string|null | $lang | ||
string|null | $list | ||
bool|null | $loop | ||
float|null | $low | ||
float|null | $max | ||
int|null | $maxlength | ||
int|null | $minlength | ||
string|null | $media | ||
string|null | $method | ||
float|null | $min | ||
bool|null | $multiple | ||
bool|null | $muted | ||
string|null | $name | ||
bool|null | $novalidate | ||
bool|null | $open | ||
float|null | $optimum | ||
string|null | $pattern | ||
string|null | $ping | ||
string|null | $placeholder | ||
string|null | $poster | ||
string|null | $preload | ||
string|null | $radiogroup | ||
bool|null | $readonly | ||
string|null | $rel | ||
bool|null | $required | ||
bool|null | $reversed | ||
int|null | $rows | ||
int|null | $rowspan | ||
string|null | $sandbox | ||
string|null | $scope | ||
bool|null | $selected | ||
string|null | $shape | ||
int|null | $size | ||
string|null | $sizes | ||
string|null | $slot | ||
int|null | $span | ||
string|null | $spellcheck | ||
string|null | $src | ||
string|null | $srcdoc | ||
string|null | $srclang | ||
string|null | $srcset | ||
int|null | $start | ||
float|null | $step | ||
string|null | $style | ||
int|null | $tabindex | ||
string|null | $target | ||
string|null | $title | ||
string|null | $translate | ||
string|null | $type | ||
string|null | $usemap | ||
string|null | $value | ||
int|null | $width | ||
string|null | $wrap |
Methods
Converts to HTML.
Converts to plain text.
Converts given HTML code to plain text.
Returns element's name.
Is element empty?
Sets multiple attributes.
Appends value to element's attribute.
Sets element's attribute.
Returns element's attribute.
Unsets element's attribute.
Unsets element's attributes.
Overloaded setter for element's attribute.
Overloaded getter for element's attribute.
Overloaded tester for element's attribute.
Overloaded unsetter for element's attribute.
Overloaded setter for element's attribute.
Setter for data-* attributes. Booleans are converted to 'true' resp. 'false'.
Returns element's HTML content.
Returns element's textual content.
Returns child node (\ArrayAccess implementation).
Exists child node? (\ArrayAccess implementation).
Removes child node (\ArrayAccess implementation).
Returns children count.
Removes all children.
Iterates over elements.
Returns all children.
Renders element's start tag, content and end tag.
Returns string in HTML format
Returns element's start tag.
Returns element's end tag.
Returns element's attributes.
Clones all children too.
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
Details
at line 266
static Html
el(string|null $name = null, array|string $attrs = null)
Constructs new HTML element.
at line 292
static Html
fromHtml(string $html)
Returns an object representing HTML text.
at line 301
static Html
fromText(string $text)
Returns an object representing plain text.
at line 310
final string
toHtml()
Converts to HTML.
at line 319
final string
toText()
Converts to plain text.
at line 328
static string
htmlToText(string $html)
Converts given HTML code to plain text.
at line 338
final Html
setName(string $name, bool|null $isEmpty = null)
Changes element's name.
at line 349
final string
getName()
Returns element's name.
at line 358
final bool
isEmpty()
Is element empty?
at line 368
Html
addAttributes(array $attrs)
Sets multiple attributes.
at line 381
Html
appendAttribute(string $name, mixed $value, mixed $option = true)
Appends value to element's attribute.
at line 406
Html
setAttribute(string $name, mixed $value)
Sets element's attribute.
at line 417
mixed
getAttribute(string $name)
Returns element's attribute.
at line 427
Html
removeAttribute(string $name)
Unsets element's attribute.
at line 438
Html
removeAttributes(array $attributes)
Unsets element's attributes.
at line 452
final void
__set(string $name, mixed $value)
Overloaded setter for element's attribute.
at line 462
final mixed
__get(string $name)
Overloaded getter for element's attribute.
at line 471
final bool
__isset(string $name)
Overloaded tester for element's attribute.
at line 480
final void
__unset(string $name)
Overloaded unsetter for element's attribute.
at line 490
final mixed
__call(string $m, array $args)
Overloaded setter for element's attribute.
at line 521
final Html
href(string $path, array|null $query = null)
Special setter for element's attribute.
at line 540
Html
data(string $name, mixed $value = null)
Setter for data-* attributes. Booleans are converted to 'true' resp. 'false'.
at line 559
final Html
setHtml(HtmlStringable|string $html)
Sets element's HTML content.
at line 569
final string
getHtml()
Returns element's HTML content.
at line 580
final Html
setText(HtmlStringable|string|int|float $text)
Sets element's textual content.
at line 594
final string
getText()
Returns element's textual content.
at line 605
final Html
addHtml(HtmlStringable|string $child)
Adds new element's child.
at line 616
Html
addText(HtmlStringable|string|int|float $text)
Appends plain-text string to element content.
at line 631
final Html
create(string $name, array|string $attrs = null)
Creates and adds a new Html child.
at line 643
Html
insert(int|null $index, HtmlStringable|string $child, bool $replace = false)
Inserts child node.
at line 662
final void
offsetSet(int|null $index, Html|string $child)
Inserts (replaces) child node (\ArrayAccess implementation).
at line 673
final HtmlStringable|string
offsetGet(int $index)
Returns child node (\ArrayAccess implementation).
at line 684
final bool
offsetExists(int $index)
Exists child node? (\ArrayAccess implementation).
at line 694
void
offsetUnset(int $index)
Removes child node (\ArrayAccess implementation).
at line 705
final int
count()
Returns children count.
at line 714
void
removeChildren()
Removes all children.
at line 724
final ArrayIterator
getIterator()
Iterates over elements.
at line 733
final array
getChildren()
Returns all children.
at line 742
final string
render(int|null $indent = null)
Renders element's start tag, content and end tag.
at line 772
final string
__toString()
Returns string in HTML format
at line 790
final string
startTag()
Returns element's start tag.
at line 801
final string
endTag()
Returns element's end tag.
at line 811
final string
attributes()
internal |
Returns element's attributes.
at line 879
__clone()
Clones all children too.
at line 234
self
accept(?string $val)
No description
at line 234
self
accesskey(?string $val, bool $state = null)
No description
at line 234
self
action(?string $val)
No description
at line 234
self
align(?string $val)
No description
at line 234
self
allow(?string $val, bool $state = null)
No description
at line 234
self
alt(?string $val)
No description
at line 234
self
async(?bool $val)
No description
at line 234
self
autocapitalize(?string $val)
No description
at line 234
self
autocomplete(?string $val)
No description
at line 234
self
autofocus(?bool $val)
No description
at line 234
self
autoplay(?bool $val)
No description
at line 234
self
charset(?string $val)
No description
at line 234
self
checked(?bool $val)
No description
at line 234
self
cite(?string $val)
No description
at line 234
self
class(?string $val, bool $state = null)
No description
at line 234
self
cols(?int $val)
No description
at line 234
self
colspan(?int $val)
No description
at line 234
self
content(?string $val)
No description
at line 234
self
contenteditable(?bool $val)
No description
at line 234
self
controls(?bool $val)
No description
at line 234
self
coords(?string $val)
No description
at line 234
self
crossorigin(?string $val)
No description
at line 234
self
datetime(?string $val)
No description
at line 234
self
decoding(?string $val)
No description
at line 234
self
default(?bool $val)
No description
at line 234
self
defer(?bool $val)
No description
at line 234
self
dir(?string $val)
No description
at line 234
self
dirname(?string $val)
No description
at line 234
self
disabled(?bool $val)
No description
at line 234
self
download(?bool $val)
No description
at line 234
self
draggable(?string $val)
No description
at line 234
self
dropzone(?string $val)
No description
at line 234
self
enctype(?string $val)
No description
at line 234
self
for(?string $val)
No description
at line 234
self
form(?string $val)
No description
at line 234
self
formaction(?string $val)
No description
at line 234
self
formenctype(?string $val)
No description
at line 234
self
formmethod(?string $val)
No description
at line 234
self
formnovalidate(?bool $val)
No description
at line 234
self
formtarget(?string $val)
No description
at line 234
self
headers(?string $val, bool $state = null)
No description
at line 234
self
height(?int $val)
No description
at line 234
self
hidden(?bool $val)
No description
at line 234
self
high(?float $val)
No description
at line 234
self
hreflang(?string $val)
No description
at line 234
self
id(?string $val)
No description
at line 234
self
integrity(?string $val)
No description
at line 234
self
inputmode(?string $val)
No description
at line 234
self
ismap(?bool $val)
No description
at line 234
self
itemprop(?string $val)
No description
at line 234
self
kind(?string $val)
No description
at line 234
self
label(?string $val)
No description
at line 234
self
lang(?string $val)
No description
at line 234
self
list(?string $val)
No description
at line 234
self
loop(?bool $val)
No description
at line 234
self
low(?float $val)
No description
at line 234
self
max(?float $val)
No description
at line 234
self
maxlength(?int $val)
No description
at line 234
self
minlength(?int $val)
No description
at line 234
self
media(?string $val)
No description
at line 234
self
method(?string $val)
No description
at line 234
self
min(?float $val)
No description
at line 234
self
multiple(?bool $val)
No description
at line 234
self
muted(?bool $val)
No description
at line 234
self
name(?string $val)
No description
at line 234
self
novalidate(?bool $val)
No description
at line 234
self
open(?bool $val)
No description
at line 234
self
optimum(?float $val)
No description
at line 234
self
pattern(?string $val)
No description
at line 234
self
ping(?string $val, bool $state = null)
No description
at line 234
self
placeholder(?string $val)
No description
at line 234
self
poster(?string $val)
No description
at line 234
self
preload(?string $val)
No description
at line 234
self
radiogroup(?string $val)
No description
at line 234
self
readonly(?bool $val)
No description
at line 234
self
rel(?string $val)
No description
at line 234
self
required(?bool $val)
No description
at line 234
self
reversed(?bool $val)
No description
at line 234
self
rows(?int $val)
No description
at line 234
self
rowspan(?int $val)
No description
at line 234
self
sandbox(?string $val, bool $state = null)
No description
at line 234
self
scope(?string $val)
No description
at line 234
self
selected(?bool $val)
No description
at line 234
self
shape(?string $val)
No description
at line 234
self
size(?int $val)
No description
at line 234
self
sizes(?string $val)
No description
at line 234
self
slot(?string $val)
No description
at line 234
self
span(?int $val)
No description
at line 234
self
spellcheck(?string $val)
No description
at line 234
self
src(?string $val)
No description
at line 234
self
srcdoc(?string $val)
No description
at line 234
self
srclang(?string $val)
No description
at line 234
self
srcset(?string $val)
No description
at line 234
self
start(?int $val)
No description
at line 234
self
step(?float $val)
No description
at line 234
self
style(?string $property, string $val = null)
No description
at line 234
self
tabindex(?int $val)
No description
at line 234
self
target(?string $val)
No description
at line 234
self
title(?string $val)
No description
at line 234
self
translate(?string $val)
No description
at line 234
self
type(?string $val)
No description
at line 234
self
usemap(?string $val)
No description
at line 234
self
value(?string $val)
No description
at line 234
self
width(?int $val)
No description
at line 234
self
wrap(?string $val)
No description
Traits
Strict class for better experience.