Html
class Html implements ArrayAccess, Countable, IteratorAggregate, HtmlStringable
HTML helper.
Properties
array<string,mixed> | $attrs | ||
static | $emptyElements | void elements |
|
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
Constructs new HTML element.
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.
Inserts child node.
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 261
static Html
el(string|null $name = null, array|string|null $attrs = null)
Constructs new HTML element.
at line 287
static Html
fromHtml(string $html)
Returns an object representing HTML text.
at line 296
static Html
fromText(string $text)
Returns an object representing plain text.
at line 305
final string
toHtml()
Converts to HTML.
at line 314
final string
toText()
Converts to plain text.
at line 323
static string
htmlToText(string $html)
Converts given HTML code to plain text.
at line 332
final Html
setName(string $name, bool|null $isEmpty = null)
Changes element's name.
at line 343
final string
getName()
Returns element's name.
at line 352
final bool
isEmpty()
Is element empty?
at line 361
Html
addAttributes(array $attrs)
Sets multiple attributes.
at line 371
Html
appendAttribute(string $name, mixed $value, mixed $option = true)
Appends value to element's attribute.
at line 394
Html
setAttribute(string $name, mixed $value)
Sets element's attribute.
at line 404
mixed
getAttribute(string $name)
Returns element's attribute.
at line 413
Html
removeAttribute(string $name)
Unsets element's attribute.
at line 423
Html
removeAttributes(array $attributes)
Unsets element's attributes.
at line 436
final void
__set(string $name, mixed $value)
Overloaded setter for element's attribute.
at line 445
final mixed
__get(string $name)
Overloaded getter for element's attribute.
at line 454
final bool
__isset(string $name)
Overloaded tester for element's attribute.
at line 463
final void
__unset(string $name)
Overloaded unsetter for element's attribute.
at line 472
final mixed
__call(string $m, array $args)
Overloaded setter for element's attribute.
at line 502
final Html
href(string $path, array $query = [])
Special setter for element's attribute.
at line 519
Html
data(string $name, mixed $value = null)
Setter for data-* attributes. Booleans are converted to 'true' resp. 'false'.
at line 536
final Html
setHtml(mixed $html)
Sets element's HTML content.
at line 546
final string
getHtml()
Returns element's HTML content.
at line 555
final Html
setText(mixed $text)
Sets element's textual content.
at line 569
final string
getText()
Returns element's textual content.
at line 578
final Html
addHtml(mixed $child)
Adds new element's child.
at line 587
Html
addText(mixed $text)
Appends plain-text string to element content.
at line 600
final Html
create(string $name, array|string|null $attrs = null)
Creates and adds a new Html child.
at line 610
Html
insert(int|null $index, HtmlStringable|string $child, bool $replace = false)
Inserts child node.
at line 629
final void
offsetSet(int|null $index, Html|string $child)
Inserts (replaces) child node (\ArrayAccess implementation).
at line 639
final HtmlStringable|string
offsetGet(int $index)
Returns child node (\ArrayAccess implementation).
at line 649
final bool
offsetExists(int $index)
Exists child node? (\ArrayAccess implementation).
at line 659
void
offsetUnset(int $index)
Removes child node (\ArrayAccess implementation).
at line 670
final int
count()
Returns children count.
at line 679
void
removeChildren()
Removes all children.
at line 689
final ArrayIterator
getIterator()
Iterates over elements.
at line 698
final array
getChildren()
Returns all children.
at line 707
final string
render(int|null $indent = null)
Renders element's start tag, content and end tag.
at line 737
final string
__toString()
Returns string in HTML format
at line 746
final string
startTag()
Returns element's start tag.
at line 757
final string
endTag()
Returns element's end tag.
at line 767
final string
attributes()
internal |
Returns element's attributes.
at line 831
__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.