Professional CodeIgniter

(singke) #1

Chapter 3: A 10,000 - Foot View of CodeIgniter


61


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 used helpers in the CodeIgniter toolbox.

HTML — The HTML helper contains functions that help you create HTML blocks quickly and
easily. For example, the ul() function can turn an array of items into a bulleted list.

Inflector — The Inflector helper contains functions that help you to turn words into plural or
singular form, to apply camel case, or to turn words separated by spaces into an underscored
phrase. For example, the singular() function can turn the string “ girls ” into “ girl. ”

Security — The Security helper contains security - related functions like xss_clean() , which
filters out any code that may be used in a cross site scripting hack.

Smiley — The Smiley helper contains functions that help you manage emoticons. The functions
in this helper might seem superfluous, but become invaluable if you are coding a bulletin board
or chat application.

String — The String helper contains functions that help you work with strings, like the random_
string() function, which as its name implies, creates random strings based on type and length
arguments.

Te x t — The Text helper contains functions that help you work with text. For example, the word_
limiter() function can limit a string to a certain number of words, which is useful if you ’ re
trying to limit user input on a form.

Typography — The Typography helper contains a single function that helps you format text in
appropriate ways. For example, the auto_typography() function wraps paragraphs with < p >
and < /p > , converts line breaks to < br/ > , and converts quotes, dashes, and ellipses properly.

URL — The URL helper contains functions that help you work with URLs. This is another helper
that sees heavy use. You will use the base_url() and anchor() functions many times in any
given project, but other functions, such as safe_mailto() and anchor_popup() are extremely
useful as well.

XML — The XML helper contains a single function that helps you work with XML. The xml_
convert() function converts a given string into XML - ready text, converting ampersands and
angle brackets (among other things) into entities.

You might be thinking to yourself, what ’ s the point of using helpers? After all, if you know your
PHP, you can use the substr() function instead of the word_limiter() or character_limiter()
made available by the Text helper. Certainly, you ’ re not forced to use helpers, but they ’ re made available
to you, and they do a fine job of saving time and effort.


As with libraries, there are simply too many helpers to cover here. Doing so would cause you to enter a
level of detail that is close to mind - numbing. However, that being said, there is good reason to pay
special attention to a pair of helpers that you will be using a lot in this and other CodeIgniter projects:
Form and URL.


❑ ❑ ❑ ❑ ❑ ❑ ❑ ❑ ❑ ❑ ❑ ❑

Free download pdf