validation_errors()

validation_errors([$prefix = ''[, $suffix = '']]) Parameters: $prefix (string) – Error opening tag $suffix (string) – Error closing tag Returns: HTML-formatted form validation error message(s) Return type: string Similarly to the form_error() function, returns all validation error messages produced by the Form Validation Library, with optional opening and closing tags around each of the messages. Example: echo validation_errors('<span class="error">', '</span>'); /*

highlight_phrase()

highlight_phrase($str, $phrase[, $tag_open = ''[, $tag_close = '']]) Parameters: $str (string) – Input string $phrase (string) – Phrase to highlight $tag_open (string) – Opening tag used for the highlight $tag_close (string) – Closing tag for the highlight Returns: String with a phrase highlighted via HTML Return type: string Will highlight a phrase within a text string. The first parameter will contain the original string, the second will contain the phrase you wish to highlight

CI_DB_result::custom_row_object()

custom_row_object($n, $type) Parameters: $n (int) – Index of the results row to return $class_name (string) – Class name for the resulting row Returns: The requested row or NULL if it doesn’t exist Return type: $type Returns the requested result row as an instance of the requested class.

CI_Zip::download()

download($filename = 'backup.zip') Parameters: $filename (string) – Archive file name Return type: void Causes the Zip file to be downloaded from your server. You must pass the name you would like the zip file called. Example: $this->zip->download('latest_stuff.zip'); // File will be named "latest_stuff.zip" Note Do not display any data in the controller in which you call this method since it sends various server headers that cause the download to happen and the file to be tre

Using CodeIgniter Libraries

All of the available libraries are located in your system/libraries/ directory. In most cases, to use one of these classes involves initializing it within a controller using the following initialization method: $this->load->library('class_name'); Where ‘class_name’ is the name of the class you want to invoke. For example, to load the Form Validation Library you would do this: $this->load->library('form_validation'); Once initialized you can use it as indicated in the user guide pa

Managing your Applications

By default it is assumed that you only intend to use CodeIgniter to manage one application, which you will build in your application/ directory. It is possible, however, to have multiple sets of applications that share a single CodeIgniter installation, or even to rename or relocate your application directory. Renaming the Application Directory If you would like to rename your application directory you may do so as long as you open your main index.php file and set its name using the $applicatio

img()

img([$src = ''[, $index_page = FALSE[, $attributes = '']]]) Parameters: $src (string) – Image source data $index_page (bool) – Whether to treat $src as a routed URI string $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" /> There is an optional second parameter

CI_DB_query_builder::set()

set($key[, $value = ''[, $escape = NULL]]) Parameters: $key (mixed) – Field name, or an array of field/value pairs $value (string) – Field value, if $key is a single field $escape (bool) – Whether to escape values and identifiers Returns: CI_DB_query_builder instance (method chaining) Return type: CI_DB_query_builder Adds field/value pairs to be passed later to insert(), update() or replace().

standard_date()

standard_date([$fmt = 'DATE_RFC822'[, $time = NULL]]) Parameters: $fmt (string) – Date format $time (int) – UNIX timestamp Returns: Formatted date or FALSE on invalid format Return type: string Lets you generate a date string in one of several standardized formats. Example: $format = 'DATE_RFC822'; $time = time(); echo standard_date($format, $time); Note This function is DEPRECATED. Use the native date() combined with DateTime’s format constants instead: echo date(DATE_RFC822, ti

html_escape()

html_escape($var) Parameters: $var (mixed) – Variable to escape (string or array) Returns: HTML escaped string(s) Return type: mixed This function acts as an alias for PHP’s native htmlspecialchars() function, with the advantage of being able to accept an array of strings. It is useful in preventing Cross Site Scripting (XSS).