HtmlTag
in package
HTML Tag Class
Tags
Table of Contents
Properties
- $attributes : array<string|int, mixed>
- The attributes of the tag
- $first_child : mixed
- The first child of the tag
- $name : string
- The tag name, like 'div' or 'img'
- $next_sibling : mixed
- The next sibling of the tag
Methods
- __construct() : mixed
- Construct a Tag object
- getAttributes() : array<string|int, mixed>
- Returns the attributes array
- getAttributeString() : string
- Returns the string representation of the tag's attributes
- getAttributeValue() : string
- Returns the value for the given attribute name
- getName() : string
- Returns the name of the tag object
- setAttribute() : void
- Sets the value of the given attribute
- toString() : string
- Returns the string representation of the tag
Properties
$attributes
The attributes of the tag
private
array<string|int, mixed>
$attributes
= array()
$first_child
The first child of the tag
private
mixed
$first_child
= \false
May be empty, a HtmlTag object or a string
$name
The tag name, like 'div' or 'img'
private
string
$name
= \false
$next_sibling
The next sibling of the tag
private
mixed
$next_sibling
= \false
May be empty, a HtmlTag object or a string
Methods
__construct()
Construct a Tag object
public
__construct(string $name[, array<string|int, mixed> $attributes = array() ]) : mixed
The attributes array, if specified, must be of the form array( attribute name => attribute value, ... more ... )
Parameters
- $name : string
-
The tag name
- $attributes : array<string|int, mixed> = array()
-
The optional list of attributes
getAttributes()
Returns the attributes array
public
getAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed> —The attribute array
getAttributeString()
Returns the string representation of the tag's attributes
public
getAttributeString() : string
If there are no attributes, the empty string is returned. Otherwise, a leading space is prepended to the string.
Return values
string —The string representation of the tags' attributes
getAttributeValue()
Returns the value for the given attribute name
public
getAttributeValue(string $name) : string
If the attribute with the given name is not present, the empty string is returned.
Parameters
- $name : string
-
The attribute name
Return values
string —The attribute value, or the empty string
getName()
Returns the name of the tag object
public
getName() : string
Return values
string —The tag name
setAttribute()
Sets the value of the given attribute
public
setAttribute(string $name, string $value) : void
If the value is empty, the attribute is removed.
Parameters
- $name : string
-
The attribute name
- $value : string
-
The attribute value
toString()
Returns the string representation of the tag
public
toString() : string
Return values
string —The string representation of the tag