CodeIgniter Common Functions

There are some common functions, which do not need to be initialized. They are globally defined.

is_php($version)
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 bool
Description Determines if the PHP version being used is greater than the supplied version number.
is_really_writable($file)
Syntax is_really_writable($file)
Parameters $file (string) – File path
Return TRUE if the path is writable, FALSE if not
Return Type bool
Description This function determines the file is writable or not
config_item($key)
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($code[, $text = ''])
Syntax set_status_header($code[, $text = ''])
Parameters
  • $code (int) – HTTP Response status code
  • $text (string) – A custom message to set with the status code.
Return
Return Type void
Description This function Permits you to manually set a server status header.
remove_invisible_characters($str[, $url_encoded = TRUE])
Syntax remove_invisible_characters($str[, $url_encoded = TRUE])
Parameters
  • $str (string) – Input string
  • $url_encoded (bool) – Whether to remove URL-encoded characters as well.
Return Sanitized string
Return Type string
Description This function prevents inserting NULL characters between ASCII characters, like Java\0script.
html_escape($var)
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 an alias for PHP’s native htmlspecialchars() function, with the advantage of being able to accept an array of strings.It is useful in preventing Cross Site Scripting (XSS).
get_mimes()
Syntax get_mimes()
Return An associative array of file types
Return Type array
Description This function returns a reference to the MIMEs array from application/config/mimes.php.
is_https()
Syntax is_https()
Return TRUE if currently running under CLI, FALSE otherwise
Return Type bool
Description TRUE if currently running under CLI, FALSE otherwise.
is_cli()
Syntax is_cli()
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($function_name)
Syntax function_usable($function_name)
Parameters $function_name (string) – function name
Return TRUE if the function can be used, FALSE if not
Return Type bool
Description Returns TRUE if a function exists and is usable, FALSE otherwise.