html_helper.php
This file is part of CodeIgniter 4 framework.
(c) CodeIgniter Foundation admin@codeigniter.com
For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
Table of Contents
Functions
- ul() : string
- Unordered List
- ol() : string
- Ordered List
- _list() : string
- Generates the list
- img() : string
- Image
- img_data() : string
- Image (data)
- doctype() : string
- Doctype
- script_tag() : string
- Script
- link_tag() : string
- Link
- video() : string
- Video
- audio() : string
- Audio
- _media() : string
- Generate media based tag
- source() : string
- Source
- track() : string
- Track
- object() : string
- Object
- param() : string
- Param
- embed() : string
- Embed
- _has_protocol() : false|int
- Test the protocol of a URI.
- _space_indent() : string
- Provide space indenting.
Functions
ul()
Unordered List
ul(array<string|int, mixed> $list[, array<string|int, mixed>|object|string $attributes = '' ]) : string
Generates an HTML unordered list from a single or multidimensional array.
Parameters
- $list : array<string|int, mixed>
-
List entries
- $attributes : array<string|int, mixed>|object|string = ''
-
HTML attributes string, array, object
Return values
stringol()
Ordered List
ol(array<string|int, mixed> $list[, array<string|int, mixed>|object|string $attributes = '' ]) : string
Generates an HTML ordered list from a single or multidimensional array.
Parameters
- $list : array<string|int, mixed>
-
List entries
- $attributes : array<string|int, mixed>|object|string = ''
-
HTML attributes string, array, object
Return values
string_list()
Generates the list
_list([string $type = 'ul' ][, array<string|int, mixed> $list = [] ][, array<string|int, mixed>|object|string $attributes = '' ][, int $depth = 0 ]) : string
Generates an HTML ordered list from a single or multidimensional array.
Parameters
- $type : string = 'ul'
- $list : array<string|int, mixed> = []
-
List entries
- $attributes : array<string|int, mixed>|object|string = ''
-
HTML attributes string, array, object
- $depth : int = 0
Return values
stringimg()
Image
img([array<string|int, mixed>|string $src = '' ][, bool $indexPage = false ][, array<string|int, mixed>|object|string $attributes = '' ]) : string
Generates an image element
Parameters
- $src : array<string|int, mixed>|string = ''
-
Image source URI, or array of attributes and values
- $indexPage : bool = false
-
Should
Config\App::$indexPage
be added to the source path - $attributes : array<string|int, mixed>|object|string = ''
-
Additional HTML attributes
Return values
stringimg_data()
Image (data)
img_data(string $path[, string|null $mime = null ]) : string
Generates a src-ready string from an image using the "data:" protocol
Parameters
- $path : string
-
Image source path
- $mime : string|null = null
-
MIME type to use, or null to guess
Return values
stringdoctype()
Doctype
doctype([string $type = 'html5' ]) : string
Generates a page document type declaration
Examples of valid options: html5, xhtml-11, xhtml-strict, xhtml-trans, xhtml-frame, html4-strict, html4-trans, and html4-frame. All values are saved in the doctypes config file.
Parameters
- $type : string = 'html5'
-
The doctype to be generated
Return values
stringscript_tag()
Script
script_tag([array<string|int, mixed>|string $src = '' ][, bool $indexPage = false ]) : string
Generates link to a JS file
Parameters
- $src : array<string|int, mixed>|string = ''
-
Script source or an array of attributes
- $indexPage : bool = false
-
Should
Config\App::$indexPage
be added to the JS path
Return values
stringlink_tag()
Link
link_tag([array<string, bool|string>|string $href = '' ][, string $rel = 'stylesheet' ][, string $type = 'text/css' ][, string $title = '' ][, string $media = '' ][, bool $indexPage = false ][, string $hreflang = '' ]) : string
Generates link tag
Parameters
- $href : array<string, bool|string>|string = ''
-
Stylesheet href or an array
- $rel : string = 'stylesheet'
- $type : string = 'text/css'
- $title : string = ''
- $media : string = ''
- $indexPage : bool = false
-
Should
Config\App::$indexPage
be added to the CSS path. - $hreflang : string = ''
Return values
stringvideo()
Video
video(array<string|int, mixed>|string $src[, string $unsupportedMessage = '' ][, string $attributes = '' ][, array<string|int, mixed> $tracks = [] ][, bool $indexPage = false ]) : string
Generates a video element to embed videos. The video element can contain one or more video sources
Parameters
- $src : array<string|int, mixed>|string
-
Either a source string or an array of sources
- $unsupportedMessage : string = ''
-
The message to display if the media tag is not supported by the browser
- $attributes : string = ''
-
HTML attributes
- $tracks : array<string|int, mixed> = []
- $indexPage : bool = false
-
Should
Config\App::$indexPage
be added to the source path
Return values
stringaudio()
Audio
audio(array<string|int, mixed>|string $src[, string $unsupportedMessage = '' ][, string $attributes = '' ][, array<string|int, mixed> $tracks = [] ][, bool $indexPage = false ]) : string
Generates an audio element to embed sounds
Parameters
- $src : array<string|int, mixed>|string
-
Either a source string or an array of sources
- $unsupportedMessage : string = ''
-
The message to display if the media tag is not supported by the browser.
- $attributes : string = ''
-
HTML attributes
- $tracks : array<string|int, mixed> = []
- $indexPage : bool = false
-
Should
Config\App::$indexPage
be added to the source path
Return values
string_media()
Generate media based tag
_media(string $name[, array<string|int, mixed> $types = [] ][, string $unsupportedMessage = '' ][, string $attributes = '' ][, array<string|int, mixed> $tracks = [] ]) : string
Parameters
- $name : string
- $types : array<string|int, mixed> = []
- $unsupportedMessage : string = ''
-
The message to display if the media tag is not supported by the browser.
- $attributes : string = ''
- $tracks : array<string|int, mixed> = []
Return values
stringsource()
Source
source(string $src[, string $type = 'unknown' ][, string $attributes = '' ][, bool $indexPage = false ]) : string
Generates a source element that specifies multiple media resources for either audio or video element
Parameters
- $src : string
-
The path of the media resource
- $type : string = 'unknown'
-
The MIME-type of the resource with optional codecs parameters
- $attributes : string = ''
-
HTML attributes
- $indexPage : bool = false
-
Should
Config\App::$indexPage
be added to the source path
Return values
stringtrack()
Track
track(string $src, string $kind, string $srcLanguage, string $label) : string
Generates a track element to specify timed tracks. The tracks are formatted in WebVTT format.
Parameters
- $src : string
-
The path of the .VTT file
- $kind : string
-
How the text track is meant to be used
- $srcLanguage : string
-
Language of the track text data
- $label : string
-
A user-readable title of the text track
Return values
stringobject()
Object
object(string $data[, string $type = 'unknown' ][, string $attributes = '' ][, array<string|int, mixed> $params = [] ][, bool $indexPage = false ]) : string
Generates an object element that represents the media as either image or a resource plugin such as audio, video, Java applets, ActiveX, PDF and Flash
Parameters
- $data : string
-
A resource URL
- $type : string = 'unknown'
-
Content-type of the resource
- $attributes : string = ''
-
HTML attributes
- $params : array<string|int, mixed> = []
- $indexPage : bool = false
-
Should
Config\App::$indexPage
be added to the data path
Return values
stringparam()
Param
param(string $name, string $value[, string $type = 'ref' ][, string $attributes = '' ]) : string
Generates a param element that defines parameters for the object element.
Parameters
- $name : string
-
The name of the parameter
- $value : string
-
The value of the parameter
- $type : string = 'ref'
-
The MIME-type
- $attributes : string = ''
-
HTML attributes
Return values
stringembed()
Embed
embed(string $src[, string $type = 'unknown' ][, string $attributes = '' ][, bool $indexPage = false ]) : string
Generates an embed element
Parameters
- $src : string
-
The path of the resource to embed
- $type : string = 'unknown'
-
MIME-type
- $attributes : string = ''
-
HTML attributes
- $indexPage : bool = false
-
Should
Config\App::$indexPage
be added to the source path
Return values
string_has_protocol()
Test the protocol of a URI.
_has_protocol(string $url) : false|int
Parameters
- $url : string
Return values
false|int_space_indent()
Provide space indenting.
_space_indent([int $depth = 2 ]) : string
Parameters
- $depth : int = 2