fyre / htmlhelper
A HTML helper library.
v3.1.0
2024-12-10 08:45 UTC
Requires
- fyre/config: ^4.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.59
- fyre/php-cs-fixer-config: ^1.0
- phpunit/phpunit: ^11
README
FyreHTMLHelper is a free, open-source HTML helper library for PHP.
Table Of Contents
Installation
Using Composer
composer require fyre/htmlhelper
In PHP:
use Fyre\Utility\HtmlHelper;
Basic Usage
$config
is a Config.
$html = new HtmlHelper($config);
The default character set will be resolved from the "App.charset" key in the Config.
Autoloading
It is recommended to bind the HtmlHelper to the Container as a singleton.
$container->singleton(HtmlHelper::class);
Any dependencies will be injected automatically when loading from the Container.
$html = $container->use(HtmlHelper::class);
Methods
Attributes
Generate an attribute string.
$options
is an array containing the attributes.
$attributes = $html->attributes($options);
Escape
Escape characters in a string for use in HTML.
$string
is the string to escape.
$escaped = $html->escape($string);
Get Charset
Get the character set.
$charset = $html->getCharset();
Set Charset
Set the character set.
$charset
is a string representing the character set.
$html->setCharset($charset);