PHPackages                             html5/fhtml - 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. [Templating &amp; Views](/categories/templating)
4. /
5. html5/fhtml

AbandonedArchivedLibrary[Templating &amp; Views](/categories/templating)

html5/fhtml
===========

FHtml Fluent HTML writing

0.2(9y ago)2660MITPHPPHP &gt;=7.0

Since Aug 22Pushed 9y ago1 watchersCompare

[ Source](https://github.com/dermatthes/FHtml)[ Packagist](https://packagist.org/packages/html5/fhtml)[ Docs](http://leuffen.de)[ RSS](/packages/html5-fhtml/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

[![](https://camo.githubusercontent.com/59fce411fcbe3068f4e8daf6831bb196d8a65eda54d4e87310f9404d92a13e07/68747470733a2f2f7472617669732d63692e6f72672f6465726d6174746865732f4648746d6c2e737667)](https://travis-ci.org/dermatthes/FHtml)

FHtml - Fluent HTML
===================

[](#fhtml---fluent-html)

**Fluent HTML Generator for PHP7** - Version **0.2** - **2016-08-23** - Written by Matthias Leuffen

Generating correct and secure HTML Code within your PHP-Code causes headache. Using FHtml's fluent speaking Api will save you lots of money you'd otherwise spent on aspirin.

It comes with an `@`-attribute-parser for easy and painless writing; you don't need any quotes (`'` or `"`) within your quoted strings.

Example? See the Kickstart:

Kickstart - See FHtml in action:
--------------------------------

[](#kickstart---see-fhtml-in-action)

```
echo fhtml("input @type=text @name=firstName @value=?", $_POST["firstName"]);
```

yes - no double quotes needed to generate valid and proper escaped xhtml:

```

```

Use the fluent-API to generate structures:

```
echo fhtml("div @class=style1 @style=display:block;width:100%")
        ->h1()->text("Hi there!")->end()
        ->p()
            ->input("@type=text @value=?", $someUnescapedValue);
```

yeah: Your PHP-code is shorter than the raw html! And proper indention is done as well:

```

    Hi There!

```

Have you ever written a ``-box with preselected value? This is the FHtml-way:

```
echo fhtml("select @name=select1")->options($optionsArr, $_POST["select1"]);
```

**Using an IDE (PhpStorm)?** FHtml comes with full code-completion on all layers. Stop typing - just hit `CTRL-SPACE` and `ENTER`.

Features
--------

[](#features)

- Generates proper escaped XHTML-compliant HTML5 code
- Quick writing without quoted quotes
- Full IDE support (tested on Jetbrains PhpStorm)
- Makes use of PHP7 return / parameter declaration
- Autodetecing multiple APIs compatible to I18n Plugins
- Unit-Tested and CI by TravisCI

Install
-------

[](#install)

FHtml is available as composer-package at **packagist.com**:

```
composer require html5\fhtml

```

or just add it to your `composer.json`:

```
    require: {
        "html5/fhtml": "0.2"
    }

```

*Hint: Use `composer upgrade --prefer-dist` to omit unit-tests and development files*

Error Reports
-------------

[](#error-reports)

Please report errors, wishes and feedback:

- Github-Page:
- Report Issues:

Usage
-----

[](#usage)

### @-attributes

[](#-attributes)

FHtml parses a single string input on `elem()` Method (or any direct tag-method like `div()` or `span()`) and parses it.

To inject insecure or not properly escaped values from outside, use the `?`-Placeholder construct:

**DON'T DO THAT:**

```
$t->input("@type=text @value=$userInput"); //
