Documentation

html_helper.php

This file is part of the 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

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[, mixed $attributes = '' ]) : string

Generates an HTML unordered list from an single or multi-dimensional array.

Parameters
$list : array<string|int, mixed>
$attributes : mixed = ''

HTML attributes string, array, object

Return values
string

ol()

Ordered List

ol(array<string|int, mixed> $list[, mixed $attributes = '' ]) : string

Generates an HTML ordered list from an single or multi-dimensional array.

Parameters
$list : array<string|int, mixed>
$attributes : mixed = ''

HTML attributes string, array, object

Return values
string

_list()

Generates the list

_list([string $type = 'ul' ][, mixed $list = [] ][, mixed $attributes = '' ], int $depth) : string

Generates an HTML ordered list from an single or multi-dimensional array.

Parameters
$type : string = 'ul'
$list : mixed = []
$attributes : mixed = ''

string, array, object

$depth : int
Return values
string

img()

Image

img([string|array<string|int, mixed> $src = '' ][, bool $indexPage = false ][, string|array<string|int, mixed>|object $attributes = '' ]) : string

Generates an image element

Parameters
$src : string|array<string|int, mixed> = ''

Image source URI, or array of attributes and values

$indexPage : bool = false

Whether to treat $src as a routed URI string

$attributes : string|array<string|int, mixed>|object = ''

Additional HTML attributes

Return values
string

img_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
string

doctype()

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
string

script_tag()

Script

script_tag([mixed $src = '' ][, bool $indexPage = false ]) : string

Generates link to a JS file

Parameters
$src : mixed = ''

Script source or an array

$indexPage : bool = false

Should indexPage be added to the JS path

Return values
string

Link

link_tag([mixed $href = '' ][, string $rel = 'stylesheet' ][, string $type = 'text/css' ][, string $title = '' ][, string $media = '' ][, bool $indexPage = false ][, string $hreflang = '' ]) : string

Generates link to a CSS file

Parameters
$href : mixed = ''

Stylesheet href or an array

$rel : string = 'stylesheet'
$type : string = 'text/css'
$title : string = ''
$media : string = ''
$indexPage : bool = false

should indexPage be added to the CSS path.

$hreflang : string = ''
Return values
string

video()

Video

video(mixed $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 : mixed

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
Return values
string

audio()

Audio

audio(mixed $src[, string $unsupportedMessage = '' ][, string $attributes = '' ][, array<string|int, mixed> $tracks = [] ][, bool $indexPage = false ]) : string

Generates an audio element to embed sounds

Parameters
$src : mixed

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
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
string

source()

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
Return values
string

track()

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
$srcLanguage : string
$label : string
Return values
string

object()

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
Return values
string

param()

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
string

embed()

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
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
Return values
string

Search results