PHP HTML utility module.
use \phat\Html;
echo Html::tag('strong', ['class' => 'awesome'], 'It works');
Html::tag($tagname, $atts?, $inner?)
Get an html tag (closed only if$inner
is notnull
).$atts
is string|array.Html::atts($atts)
- Convert attributes into a properly encoded string for use in html.$atts
is string|array.Html::parseAtts($atts)
- Convert attributes into an array for use in PHP.Html::esc($string)
- Escape a string for use in html. Ensure that entities are not double encoded.Html::encode($value)
- Encode a value into a string for use in an html attribute. Usesesc
orjson_encode
as needed.Html::decode($value)
- Decode a value that was previously encoded viaencode
orjson_encode
Html::implode($values, $delimiter?)
- Deep implode. Defaults to SSV.Html::explode($values, $delimiter?)
- Explode by one or more delimiters. Defaults to SSV.Html::respace($text, $replacement?)
Replace or normalize whitespace.Html::rebreak($text, $replacement?)
Replace or normalize line breaks.Html::dom($html)
- Parse markup (or an array of nodes) into aDOMDocument
object.Html::method($name)
- Get a fully-qualified method name for use likearray_map(Html::method('esc'), $array)
_e
methods echo the result of the underlying function via overloading. For example:
Html::esc_e($string)
Html::tag_e($tagname, $atts, $inner_html)