Coder Social home page Coder Social logo

html-helper's Introduction

Description

HTML Helper is a complete PHP class which provide a really simple markup which will make your HTML rendering easier than ever.


Feedback

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.


Fork it!

Please fork this project and help me with the development, I appreciate! =)


Installing

// Just include the class and you're ready to rock! :)
include_once(dirname(__FILE__) . '/class.html.php');

The $attributes variable

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.

Functions

Doctype

Return the specified doctype

// The below line will print the default doctype, which is HTML5: <!DOCTYPE html>
echo HTML::Doctype();

Available Doctypes

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

Image

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');

Anchor

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'));

Email

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');

Line break

Returns the <br /> (break) tag.

// The below line will print <br /><br /><br /> (3 times <br />)
echo HTML::LineBreak(3);

Space

Returns the &nbsp; (white space) entity .

// The below line will print &nbsp;&nbsp;&nbsp; (3 times &nbsp;)
echo HTML::Space(3);

Form

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! =)')));

HTML::Form() Usage

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 & Close

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();

Version

Return the script version (major.minor.release)

// Usage
echo HTML::Version();

html-helper's People

Contributors

mrguri avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.