create_captcha()

create_captcha([$data = ''[, $img_path = ''[, $img_url = ''[, $font_path = '']]]]) Parameters: $data (array) – Array of data for the CAPTCHA $img_path (string) – Path to create the image in $img_url (string) – URL to the CAPTCHA image folder $font_path (string) – Server path to font Returns: array(‘word’ => $word, ‘time’ => $now, ‘image’ => $img) Return type: array Takes an array of information to generate the CAPTCHA as input and creates the image to your specifications

Creating Libraries

When we use the term “Libraries” we are normally referring to the classes that are located in the libraries directory and described in the Class Reference of this user guide. In this case, however, we will instead describe how you can create your own libraries within your application/libraries directory in order to maintain separation between your local resources and the global framework resources. As an added bonus, CodeIgniter permits your libraries to extend native classes if you simply need

Custom Function Calls

$this->db->call_function(); This function enables you to call PHP database functions that are not natively included in CodeIgniter, in a platform independent manner. For example, let’s say you want to call the mysql_get_client_info() function, which is not natively supported by CodeIgniter. You could do so like this: $this->db->call_function('get_client_info'); You must supply the name of the function, without the mysql_ prefix, in the first parameter. The prefix is added automatic

Create news items

You now know how you can read data from a database using CodeIgniter, but you haven’t written any information to the database yet. In this section you’ll expand your news controller and model created earlier to include this functionality. Create a form To input data into the database you need to create a form where you can input the information to be stored. This means you’ll be needing a form with two fields, one for the title and one for the text. You’ll derive the slug from our title in the

convert_accented_characters()

convert_accented_characters($str) Parameters: $str (string) – Input string Returns: A string with accented characters converted Return type: string Transliterates high ASCII characters to low ASCII equivalents. Useful when non-English characters need to be used where only standard ASCII characters are safely used, for instance, in URLs. Example: $string = convert_accented_characters($string); Note This function uses a companion config file application/config/foreign_chars.php to d

Controllers

Controllers are the heart of your application, as they determine how HTTP requests should be handled. Page Contents ControllersWhat is a Controller? Let’s try it: Hello World! Methods Passing URI Segments to your methods Defining a Default Controller Remapping Method Calls Processing Output Private methods Organizing Your Controllers into Sub-directories Class Constructors Reserved method names That’s it! What is a Controller? A Controller is simply a class file that is named in a way that

config_item()

config_item($key) Parameters: $key (string) – Config item key Returns: Configuration key value or NULL if not found Return type: mixed The Config Library is the preferred way of accessing configuration information, however config_item() can be used to retrieve single keys. See Config Library documentation for more information.

Conclusion

This tutorial did not cover all of the things you might expect of a full-fledged content management system, but it introduced you to the more important topics of routing, writing controllers, and models. We hope this tutorial gave you an insight into some of CodeIgniter’s basic design patterns, which you can expand upon. Now that you’ve completed this tutorial, we recommend you check out the rest of the documentation. CodeIgniter is often praised because of its comprehensive documentation. Use

Connecting to your Database

There are two ways to connect to a database: Automatically Connecting The “auto connect” feature will load and instantiate the database class with every page load. To enable “auto connecting”, add the word database to the library array, as indicated in the following file: application/config/autoload.php Manually Connecting If only some of your pages require database connectivity you can manually connect to your database by adding this line of code in any function where it is needed, or in your

CodeIgniter URLs

By default, URLs in CodeIgniter are designed to be search-engine and human friendly. Rather than using the standard “query string” approach to URLs that is synonymous with dynamic systems, CodeIgniter uses a segment-based approach: example.com/news/article/my_article Note Query string URLs can be optionally enabled, as described below. URI Segments The segments in the URL, in following with the Model-View-Controller approach, usually represent: example.com/class/function/ID The first segmen