Html
class Html implements ArrayAccess, Countable, IteratorAggregate, IHtmlString
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 265
static Html
el(string $name = null, array|string $attrs = null)
Constructs new HTML element.
at line 291
static Html
fromHtml(string $html)
Returns an object representing HTML text.
at line 300
static Html
fromText(string $text)
Returns an object representing plain text.
at line 309
final string
toHtml()
Converts to HTML.
at line 318
final string
toText()
Converts to plain text.
at line 327
static string
htmlToText(string $html)
Converts given HTML code to plain text.
at line 337
final Html
setName(string $name, bool $isEmpty = null)
Changes element's name.
at line 348
final string
getName()
Returns element's name.
at line 357
final bool
isEmpty()
Is element empty?
at line 367
Html
addAttributes(array $attrs)
Sets multiple attributes.
at line 380
Html
appendAttribute(string $name, mixed $value, mixed $option = true)
Appends value to element's attribute.
at line 404
Html
setAttribute(string $name, mixed $value)
Sets element's attribute.
at line 415
mixed
getAttribute(string $name)
Returns element's attribute.
at line 425
Html
removeAttribute(string $name)
Unsets element's attribute.
at line 436
Html
removeAttributes(array $attributes)
Unsets element's attributes.
at line 449
final void
__set(string $name, mixed $value)
Overloaded setter for element's attribute.
at line 459
final mixed
__get(string $name)
Overloaded getter for element's attribute.
at line 468
final bool
__isset(string $name)
Overloaded tester for element's attribute.
at line 477
final void
__unset(string $name)
Overloaded unsetter for element's attribute.
at line 487
final mixed
__call(string $m, array $args)
Overloaded setter for element's attribute.
at line 518
final Html
href(string $path, array $query = null)
Special setter for element's attribute.
at line 536
Html
data(string $name, mixed $value = null)
Setter for data-* attributes. Booleans are converted to 'true' resp. 'false'.
at line 554
final Html
setHtml(IHtmlString|string $html)
Sets element's HTML content.
at line 564
final string
getHtml()
Returns element's HTML content.
at line 575
final Html
setText(IHtmlString|string|int|float $text)
Sets element's textual content.
at line 588
final string
getText()
Returns element's textual content.
at line 599
final Html
addHtml(IHtmlString|string $child)
Adds new element's child.
at line 610
Html
addText(IHtmlString|string|int|float $text)
Appends plain-text string to element content.
at line 624
final Html
create(string $name, array|string $attrs = null)
Creates and adds a new Html child.
at line 636
Html
insert(int|null $index, IHtmlString|string $child, bool $replace = false)
Inserts child node.
at line 655
final void
offsetSet(int|null $index, Html|string $child)
Inserts (replaces) child node (\ArrayAccess implementation).
at line 666
final HtmlStringable|string
offsetGet(int $index)
Returns child node (\ArrayAccess implementation).
at line 676
final bool
offsetExists(int $index)
Exists child node? (\ArrayAccess implementation).
at line 686
void
offsetUnset(int $index)
Removes child node (\ArrayAccess implementation).
at line 697
final int
count()
Returns children count.
at line 706
void
removeChildren()
Removes all children.
at line 716
final ArrayIterator
getIterator()
Iterates over elements.
at line 725
final array
getChildren()
Returns all children.
at line 734
final string
render(int $indent = null)
Renders element's start tag, content and end tag.
at line 762
final string
__toString()
Returns string in HTML format
at line 779
final string
startTag()
Returns element's start tag.
at line 790
final string
endTag()
Returns element's end tag.
at line 800
final string
attributes()
internal |
Returns element's attributes.
at line 867
__clone()
Clones all children too.
at line 233
self
accept(?string $val)
No description
at line 233
self
accesskey(?string $val, bool $state = null)
No description
at line 233
self
action(?string $val)
No description
at line 233
self
align(?string $val)
No description
at line 233
self
allow(?string $val, bool $state = null)
No description
at line 233
self
alt(?string $val)
No description
at line 233
self
async(?bool $val)
No description
at line 233
self
autocapitalize(?string $val)
No description
at line 233
self
autocomplete(?string $val)
No description
at line 233
self
autofocus(?bool $val)
No description
at line 233
self
autoplay(?bool $val)
No description
at line 233
self
charset(?string $val)
No description
at line 233
self
checked(?bool $val)
No description
at line 233
self
cite(?string $val)
No description
at line 233
self
class(?string $val, bool $state = null)
No description
at line 233
self
cols(?int $val)
No description
at line 233
self
colspan(?int $val)
No description
at line 233
self
content(?string $val)
No description
at line 233
self
contenteditable(?bool $val)
No description
at line 233
self
controls(?bool $val)
No description
at line 233
self
coords(?string $val)
No description
at line 233
self
crossorigin(?string $val)
No description
at line 233
self
datetime(?string $val)
No description
at line 233
self
decoding(?string $val)
No description
at line 233
self
default(?bool $val)
No description
at line 233
self
defer(?bool $val)
No description
at line 233
self
dir(?string $val)
No description
at line 233
self
dirname(?string $val)
No description
at line 233
self
disabled(?bool $val)
No description
at line 233
self
download(?bool $val)
No description
at line 233
self
draggable(?string $val)
No description
at line 233
self
dropzone(?string $val)
No description
at line 233
self
enctype(?string $val)
No description
at line 233
self
for(?string $val)
No description
at line 233
self
form(?string $val)
No description
at line 233
self
formaction(?string $val)
No description
at line 233
self
formenctype(?string $val)
No description
at line 233
self
formmethod(?string $val)
No description
at line 233
self
formnovalidate(?bool $val)
No description
at line 233
self
formtarget(?string $val)
No description
at line 233
self
headers(?string $val, bool $state = null)
No description
at line 233
self
height(?int $val)
No description
at line 233
self
hidden(?bool $val)
No description
at line 233
self
high(?float $val)
No description
at line 233
self
hreflang(?string $val)
No description
at line 233
self
id(?string $val)
No description
at line 233
self
integrity(?string $val)
No description
at line 233
self
inputmode(?string $val)
No description
at line 233
self
ismap(?bool $val)
No description
at line 233
self
itemprop(?string $val)
No description
at line 233
self
kind(?string $val)
No description
at line 233
self
label(?string $val)
No description
at line 233
self
lang(?string $val)
No description
at line 233
self
list(?string $val)
No description
at line 233
self
loop(?bool $val)
No description
at line 233
self
low(?float $val)
No description
at line 233
self
max(?float $val)
No description
at line 233
self
maxlength(?int $val)
No description
at line 233
self
minlength(?int $val)
No description
at line 233
self
media(?string $val)
No description
at line 233
self
method(?string $val)
No description
at line 233
self
min(?float $val)
No description
at line 233
self
multiple(?bool $val)
No description
at line 233
self
muted(?bool $val)
No description
at line 233
self
name(?string $val)
No description
at line 233
self
novalidate(?bool $val)
No description
at line 233
self
open(?bool $val)
No description
at line 233
self
optimum(?float $val)
No description
at line 233
self
pattern(?string $val)
No description
at line 233
self
ping(?string $val, bool $state = null)
No description
at line 233
self
placeholder(?string $val)
No description
at line 233
self
poster(?string $val)
No description
at line 233
self
preload(?string $val)
No description
at line 233
self
radiogroup(?string $val)
No description
at line 233
self
readonly(?bool $val)
No description
at line 233
self
rel(?string $val)
No description
at line 233
self
required(?bool $val)
No description
at line 233
self
reversed(?bool $val)
No description
at line 233
self
rows(?int $val)
No description
at line 233
self
rowspan(?int $val)
No description
at line 233
self
sandbox(?string $val, bool $state = null)
No description
at line 233
self
scope(?string $val)
No description
at line 233
self
selected(?bool $val)
No description
at line 233
self
shape(?string $val)
No description
at line 233
self
size(?int $val)
No description
at line 233
self
sizes(?string $val)
No description
at line 233
self
slot(?string $val)
No description
at line 233
self
span(?int $val)
No description
at line 233
self
spellcheck(?string $val)
No description
at line 233
self
src(?string $val)
No description
at line 233
self
srcdoc(?string $val)
No description
at line 233
self
srclang(?string $val)
No description
at line 233
self
srcset(?string $val)
No description
at line 233
self
start(?int $val)
No description
at line 233
self
step(?float $val)
No description
at line 233
self
style(?string $property, string $val = null)
No description
at line 233
self
tabindex(?int $val)
No description
at line 233
self
target(?string $val)
No description
at line 233
self
title(?string $val)
No description
at line 233
self
translate(?string $val)
No description
at line 233
self
type(?string $val)
No description
at line 233
self
usemap(?string $val)
No description
at line 233
self
value(?string $val)
No description
at line 233
self
width(?int $val)
No description
at line 233
self
wrap(?string $val)
No description
Traits
Strict class for better experience.