HTML Helper is a complete PHP class which provide a really simple markup which will make your HTML rendering easier than ever.
Feel free to contact me via Email anytime you want. If you like this class and use it in somewhere, please, send me a feedback with your opinion about my job.
Please fork this project and help me with the development, I appreciate! =)
// Just include the class and you're ready to rock! :)
include_once(dirname(__FILE__) . '/class.html.php');
This variable can be a string like this: 'attribute1="value1" attribute2="value2"'
.
Or an array like this: array('attribute1' => 'value1', 'attribute2' => 'value2');
.
So when you're going to set the $attributes
variable in some function, always remember the style of code that it must to be.
- HTML::Doctype(string $type);
- HTML::Image(string $src, mixed $attributes);
- HTML::Anchor(string $url, string $label, mixed $attributes);
- HTML::Email(string $email, string $label);
- HTML::LineBreak(integer $count);
- HTML::Space(integer $count);
- HTML::Form(string $action, array $fields, string $name, string $method, string $enctype);
- HTML::Open(string $tag, mixed $attributes, array $li_items);
- HTML::Close();
- HTML::Version();
Return the specified doctype
// The below line will print the default doctype, which is HTML5: <!DOCTYPE html>
echo HTML::Doctype();
html5 -> HTML5
xhtml11 -> (x)HTML 1.1
xhtml1-strict -> (x)HTML 1.0 Strict
xhtml1-trans -> (x)HTML 1.0 Transitional
xhtml1-frame -> (x)HTML 1.0 Frameset
html4-strict -> HTML4 Strict
html4-trans -> HTML4 Transitional
html4-frame -> HTML4 Frameset
Returns the <img />
tag
// The below line will print: <img src="http://example.com/location/to/image.png" border="0" />
echo HTML::Image('http://example.com/location/to/image.png');
Returns the <a></a>
with the specified attributes.
// The below line will print: <a href="http://lunnaly.com" target="_blank" title="Visit Lunnaly's Website">Lunnaly</a>
echo HTML::Anchor('http://lunnaly.com', 'Lunnaly', array('target' => '_blank', 'title' => 'Visit Lunnaly\'s Website'));
Returns a formated 'mailto' link.
// The below line will print: <a href="mailto:[email protected]">My Email</a>
echo HTML::Email('[email protected]', 'My Email');
Returns the <br />
(break) tag.
// The below line will print <br /><br /><br /> (3 times <br />)
echo HTML::LineBreak(3);
Returns the
(white space) entity .
// The below line will print (3 times )
echo HTML::Space(3);
Create the structure following: <form>$fields</form>
.
// The below line will print a 'post' form with the following 'action' attribute: 'my-file.php' and 2 fields which are: 'username' and 'password'.
echo HTML::Form('my-file.php', array('text' => array('id' => 'username', 'name' => 'username', 'placeholder' => 'I\'m a text field! =)'), 'password' => array('id' => 'password', 'name' => 'password', 'placeholder' => 'I\'m a password input! =)')));
echo HTML::Form(the 'action' file, an array with the following structure: type => array(attribute => value));
That's all you need to print a form. =)
Open a tag and pass the specified attributes to the same.
// The below line will print an opened tag
echo HTML::Open('tag', 'attribute="value"');
echo 'My content goes here';
// After you've done inserting the content, you must close the tag.
echo HTML::Close();
Return the script version (major.minor.release)
// Usage
echo HTML::Version();