blob: 73b6bccb1146733cde88dab07d22060a39abe6c5 [file] [log] [blame]
Derek Jones8ede1a22011-10-05 13:34:52 -05001################
2Common Functions
3################
4
5CodeIgniter uses a few functions for its operation that are globally
6defined, and are available to you at any point. These do not require
7loading any libraries or helpers.
8
9is_php('version_number')
10==========================
11
12is_php() determines of the PHP version being used is greater than the
13supplied version_number.
14
15::
16
17 if (is_php('5.3.0')) {     $str = quoted_printable_encode($str); }
18
19Returns boolean TRUE if the installed version of PHP is equal to or
20greater than the supplied version number. Returns FALSE if the installed
21version of PHP is lower than the supplied version number.
22
23is_really_writable('path/to/file')
24====================================
25
26is_writable() returns TRUE on Windows servers when you really can't
27write to the file as the OS reports to PHP as FALSE only if the
28read-only attribute is marked. This function determines if a file is
29actually writable by attempting to write to it first. Generally only
30recommended on platforms where this information may be unreliable.
31
32::
33
34 if (is_really_writable('file.txt')) {     echo "I could write to this if I wanted to"; } else {     echo "File is not writable"; }
35
36config_item('item_key')
37=========================
38
39The :doc:`Config library <../libraries/config>` is the preferred way of
40accessing configuration information, however config_item() can be used
41to retrieve single keys. See Config library documentation for more
42information.
43
44show_error('message'), show_404('page'), log_message('level',
45'message')
46==========
47
48These are each outlined on the :doc:`Error Handling <errors>` page.
49
50set_status_header(code, 'text');
51==================================
52
53Permits you to manually set a server status header. Example::
54
55 set_status_header(401); // Sets the header as: Unauthorized
56
57`See here <http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html>`_ for
58a full list of headers.
59
60remove_invisible_characters($str)
61===================================
62
63This function prevents inserting null characters between ascii
64characters, like Java\\0script.
65
66html_escape($mixed)
67====================
68
69This function provides short cut for htmlspecialchars() function. It
70accepts string and array. To prevent Cross Site Scripting (XSS), it is
71very useful.