HTML Helper¶
The HTML Helper file contains functions that assist in working with HTML.
Available Functions¶
The following functions are available:
-
img
($src = '', $attributes = '')¶ -
Parameters: - $src (string) – Image source data
- $attributes (array) – HTML attributes
Returns: HTML image tag
Return type: string
Lets you create HTML <img /> tags. The first parameter contains the image source. Example:
echo img('images/picture.jpg'); // gives <img src="http://site.com/images/picture.jpg" />
Additionally, an associative array can be passed to the
img()
function for complete control over all attributes and values. If an alt attribute is not provided, Codingox will generate an empty string.Example:
$image_properties = array( 'src' => 'images/picture.jpg', 'alt' => 'Me, demonstrating how to eat 4 slices of pizza at one time', 'class' => 'post_images', 'width' => '200', 'height'=> '200', 'title' => 'That was quite a night', 'rel' => 'lightbox' ); img($image_properties); // <img src="http://site.com/images/picture.jpg" alt="Me, demonstrating how to eat 4 slices of pizza at one time" class="post_images" width="200" height="200" title="That was quite a night" rel="lightbox" />
-
link_tag
($href = '', $rel = 'stylesheet')¶ -
Parameters: - $href (string) – What are we linking to
- $rel (string) – Relation type
Returns: HTML link tag
Return type: string
Lets you create HTML <link /> tags. This is useful for stylesheet links, as well as other links. The parameters are href, with optional rel.
Example:
echo link_tag('css/mystyles.css'); // gives <link href="http://site.com/css/mystyles.css" rel="stylesheet" type="text/css" />
Further examples:
echo link_tag('favicon.ico', 'icon'); // <link href="http://site.com/favicon.ico" rel="icon" />
Additionally, an associative array can be passed to the
link_tag()
function for complete control over all attributes and values:$link = array( 'href' => 'css/printer.css', 'rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'print' ); echo link_tag($link); // <link href="http://site.com/css/printer.css" rel="stylesheet" type="text/css" media="print" />
-
script_tag
($src = '')¶ -
Parameters: - $src (string) – What are we linking to
Returns: HTML script tag
Return type: string
Lets you create HTML <script></script> tags. This is useful for javascript links.
Example:
echo script_tag('js/myscript.js'); // gives <script src="http://site.com/js/myscript.js"></script>
-
a_href
($url = '', $content = '')¶ -
Parameters: - $url (string)
- $content (string)
Returns: HTML anchor tag
Return type: string
Lets you create HTML <a href=''></a> tags.
Example:
echo a_href('blog/myarticle', 'Article'); // gives <a href="http://site.com/blog/myarticle">Article</a>
-
alert_message
($type = '', $message = '')¶ -
Parameters: - $type (string) - success OR error
- $message (string)
Return type: string
-
bootstrap
()¶ -
Returns: Bootstrap CDN Files
Return type: string
-
div_open
($attribute = '')¶ -
Parameters: - $attribute (array)
Returns: HTML div open tag
Return type: string
-
html_open
()¶ -
Returns: HTML open tag
Return type: string