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

Using CodeIgniter Drivers

Drivers are a special type of Library that has a parent class and any number of potential child classes. Child classes have access to the parent class, but not their siblings. Drivers provide an elegant syntax in your controllers for libraries that benefit from or require being broken down into discrete classes. Drivers are found in the system/libraries/ directory, in their own sub-directory which is identically named to the parent library class. Also inside that directory is a subdirectory nam

url_title()

url_title($str, $separator = '-', $lowercase = FALSE) Parameters: $str (string) – Input string $separator (string) – Word separator $lowercase (bool) – Whether to transform the output string to lower-case Returns: URL-formatted string Return type: string Takes a string as input and creates a human-friendly URL string. This is useful if, for example, you have a blog in which you’d like to use the title of your entries in the URL. Example: $title = "What's wrong with CSS?"; $url_tit

uri_string()

uri_string() Returns: An URI string Return type: string Returns the URI segments of any page that contains this function. For example, if your URL was this: http://some-site.com/blog/comments/123 The function would return: blog/comments/123 This function is an alias for CI_Config::uri_string(). For more info, please see the Config Library documentation.

URI Routing

Typically there is a one-to-one relationship between a URL string and its corresponding controller class/method. The segments in a URI normally follow this pattern: example.com/class/function/id/ In some instances, however, you may want to remap this relationship so that a different class/method can be called instead of the one corresponding to the URL. For example, let’s say you want your URLs to have this prototype: example.com/product/1/ example.com/product/2/ example.com/product/3/ example

Upgrading From a Previous Version

Please read the upgrade notes corresponding to the version you are upgrading from. Upgrading from 3.0.6 to 3.1.0 Upgrading from 3.0.5 to 3.0.6 Upgrading from 3.0.4 to 3.0.5 Upgrading from 3.0.3 to 3.0.4 Upgrading from 3.0.2 to 3.0.3 Upgrading from 3.0.1 to 3.0.2 Upgrading from 3.0.0 to 3.0.1 Upgrading from 2.2.x to 3.0.x Upgrading from 2.2.2 to 2.2.3 Upgrading from 2.2.1 to 2.2.2 Upgrading from 2.2.0 to 2.2.1 Upgrading from 2.1.4 to 2.2.x Upgrading from 2.1.3 to 2.1.4

unix_to_human()

unix_to_human([$time = ''[, $seconds = FALSE[, $fmt = 'us']]]) Parameters: $time (int) – UNIX timestamp $seconds (bool) – Whether to show seconds $fmt (string) – format (us or euro) Returns: Formatted date Return type: string Takes a UNIX timestamp as input and returns it in a human readable format with this prototype: YYYY-MM-DD HH:MM:SS AM/PM This can be useful if you need to display a date in a form field for submission. The time can be formatted with or without seconds, and i

underscore()

underscore($str) Parameters: $str (string) – Input string Returns: String containing underscores instead of spaces Return type: string Takes multiple words separated by spaces and underscores them. Example: echo underscore('my dog spot'); // Prints 'my_dog_spot'

ul()

ul($list[, $attributes = '']) Parameters: $list (array) – List entries $attributes (array) – HTML attributes Returns: HTML-formatted unordered list Return type: string Permits you to generate unordered HTML lists from simple or multi-dimensional arrays. Example: $list = array( 'red', 'blue', 'green', 'yellow' ); $attributes = array( 'class' => 'boldlist', 'id' => 'mylist' ); echo ul($list, $attributes); The above code will

Tutorial

This tutorial is intended to introduce you to the CodeIgniter framework and the basic principles of MVC architecture. It will show you how a basic CodeIgniter application is constructed in step-by-step fashion. In this tutorial, you will be creating a basic news application. You will begin by writing the code that can load static pages. Next, you will create a news section that reads news items from a database. Finally, you’ll add a form to create news items in the database. This tutorial will