ContentInterface
API reference › HTML Contracts › Element › ContentInterface
Implemented by 2 types
Defines the contract for elements that accept child content.
Content appended through content() is encoded, whereas content appended through html() is preserved
verbatim.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
content() abstract | Appends encoded content. | ContentInterface |
getContent() abstract | Returns the content assigned to the element. | ContentInterface |
html() abstract | Appends trusted raw HTML content without encoding or sanitizing it. | ContentInterface |
Method details
Section titled “Method details”content()
Section titled “content() ”abstract public function content(string|Stringable|UnitEnum ...$values): staticAppends encoded content.
Backed enums use their value (including 0); pure enums use their name. Values are normalized before encoding.
Parameters
| Parameter | Type | Description |
|---|---|---|
...$values | string|Stringable|UnitEnum | Content to be encoded and appended. |
Returns
static: New instance with appended encoded content.
getContent()
Section titled “getContent() ”abstract public function getContent(): stringReturns the content assigned to the element.
Returns
string: Content value assigned to the element. Never null.
html()
Section titled “html() ”abstract public function html(string|Stringable|UnitEnum ...$values): staticAppends trusted raw HTML content without encoding or sanitizing it.
Backed enums use their value (including 0); pure enums use their name.
Parameters
| Parameter | Type | Description |
|---|---|---|
...$values | string|Stringable|UnitEnum | Trusted raw HTML content to be appended. |
Returns
static: New instance with appended raw HTML content.