CodeIgniter Common Functions
CodeIgniter uses a few common functions for its operation that are globally defined, and are available to you at any point. These do not require loading any libraries or helpers.
- is_php()
- is_really_writable()
- config_item()
- set_status_header()
- html_escape()
- get_mimes()
- is_https()
- is_cli()
- function_usable()
is_php()
This function if the PHP version being used is greater than the supplied version number.
Syntax | is_php($version) |
---|---|
Parameters | $version (string) ? Version number |
Return | TRUE if the running PHP version is at least the one specified or FALSE if not Return Type void |
Description | Determines if the PHP version being used is greater than the supplied version number. |
is_really_writable()
This function checks to see if file is writable or not.
Syntax | is_really_writable($file) |
---|---|
Parameters | $file (string) ? File path |
Return | TRUE if the path is writable, FALSE if not Return Type bool |
Description | Checks to see if file is writable or not. |
config_item()
This function is used to get the configuration item
Syntax | config_item($key) |
---|---|
Parameters | $key (string) ? Config item key |
Return | Configuration key value or NULL if not found Return Type mixed |
Description | This function is used to get the configuration item |
set_status_header()
This function permits you to manually set a server status header.
Syntax | set_status_header($code[, $text = '']) |
---|---|
Parameters | $text (string) ? A custom message to set with the status code , $code (int) ? HTTP Response status code |
Return | Return Type void |
Description | This function is used to get the configuration item |
html_escape()
This function acts as a native PHP htmlspecialchars() function.
Syntax | html_escape($var) |
---|---|
Parameters | $var (mixed) ? Variable to escape (string or array) |
Return | HTML escaped string(s) Return Type mixed |
Description | This function acts as a native PHP htmlspecialchars() function. |
get_mimes()
This function acts as a native PHP htmlspecialchars() function.
Syntax | get_mimes() |
---|---|
Parameters | An associative array of file types Return Type array |
Return | HTML escaped string(s) Return Type mixed |
Description | This function returns a reference to the MIMEs array from application/config/mimes.php. |
is_https()
This function Returns TRUE if a secure (HTTPS) connection is used and FALSE in any other case (including non-HTTP requests).
Syntax | get_mimes() |
---|---|
Return | TRUE if currently using HTTP-over-SSL, FALSE if not Return Type bool |
Description | Returns TRUE if a secure (HTTPS) connection is used and FALSE in any other case (including non-HTTP requests). |
is_cli()
This function Returns TRUE if a secure (HTTPS) connection is used and FALSE in any other case (including non-HTTP requests).
Syntax | get_mimes() |
---|---|
Return | TRUE if currently running under CLI, FALSE otherwise Return Type bool |
Description | Returns TRUE if the application is run through the command line and FALSE if not. |
function_usable()
This function Returns TRUE if a function exists and is usable, FALSE otherwise.
Syntax | get_mimes() |
---|---|
Parameters | $function_name (string) ? Function name |
Return | Return Type bool |
Description | Returns TRUE if a function exists and is usable, FALSE otherwise. |