PHPackages                             rchipka/tagbuilder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. rchipka/tagbuilder

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rchipka/tagbuilder
==================

04261PHP

Since Jul 23Pushed 7y ago1 watchersCompare

[ Source](https://github.com/rchipka/php-tagbuilder)[ Packagist](https://packagist.org/packages/rchipka/tagbuilder)[ RSS](/packages/rchipka-tagbuilder/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (1)

PHP TagBuilder
==============

[](#php-tagbuilder)

A lightweight HTML tag building API for PHP

Benefits:
---------

[](#benefits)

- No more HTML mangling and switching between &lt;?php mode
- No more inline attribute logic/toggling
- Less painful echoing, concatenating
- Easily store HTML tags in a variable
- Impossible to write malformed HTML (PHP brackets require balance)
- Auto-escaped attribute values
- Able hook/filter all elements/content/attributes
- Integration with VBTK Context for granular hooking/filtering
- Won't show tags with empty content (no more if !empty() logic)

Usage:
------

[](#usage)

\_*tagname*() &lt;- echo html \_\_*tagname*() &lt;- return html

### Args:

[](#args)

\_*tagname*($attributes, $content)

$attributes - optional - key/value array of attributes

- values can be strings, numbers, or arrays
- given a plain sequential array (numeric keys), values will default to the `class` attr
- if an attribute is set to a key/value array, then the value will determine whether to include the corresponding key (useful for class toggling)

$content - optional - value or array of values

- values can be strings, functions or an array of strings and functions

Examples
--------

[](#examples)

```
