O'Reilly logo

Professional CodeIgniter® by Thomas Myer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.5. CodeIgniter Helpers

Helpers, as their name implies, help you with specific tasks. Unlike libraries, helpers are not object-oriented but procedural in nature. Each helper contains one or more functions, each focusing on a specific task, with zero dependence on other functions.

Helpers can either be loaded locally or autoloaded in /system/application/config/autoload.php. CodeIgniter ships with the following built-in helpers:

  • Array — The Array helper contains functions that help you work with arrays. For example, the random_element() function takes an array as input and returns a random element from it.

  • Cookie — The Cookie helper contains functions that help you set, read, and delete cookie data.

  • Date — The Date helper contains functions that help you work with dates. For example, the now() function returns the current time as a UNIX time stamp.

  • Directory — The Directory helper contains a single function that helps you work with directories. For example, the directory_map function reads a specified directory path and builds an array of it that contains all of its files and subdirectories.

  • Download — The Download helper contains a single function that helps you download data easily. The force_download() function generates server headers that force data to be downloaded instead of viewed in a browser.

  • File — The File helper contains functions that help you read, write, and delete files.

  • Form — The Form helper contains functions that help you build forms. It is probably one of the most ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required