write_file()

write_file($path, $data[, $mode = 'wb']) Parameters: $path (string) – File path $data (string) – Data to write to file $mode (string) – fopen() mode Returns: TRUE if the write was successful, FALSE in case of an error Return type: bool Writes data to the file specified in the path. If the file does not exist then the function will create it. Example: $data = 'Some file data'; if ( ! write_file('./path/to/file.php', $data)) { echo 'Unable to write the file'; } else {

Database Caching Class

The Database Caching Class permits you to cache your queries as text files for reduced database load. Important This class is initialized automatically by the database driver when caching is enabled. Do NOT load this class manually. Important Not all query result functions are available when you use caching. Please read this page carefully. Enabling Caching Caching is enabled in three steps: Create a writable directory on your server where the cache files can be stored. Set the path to your

CI_Session::sess_regenerate()

sess_regenerate([$destroy = FALSE]) Parameters: $destroy (bool) – Whether to destroy session data Return type: void Regenerate session ID, optionally destroying the current session’s data. Note This method is just an alias for PHP’s native session_regenerate_id() function.

CI_Email::attachment_cid()

attachment_cid($filename) Parameters: $filename (string) – Existing attachment filename Returns: Attachment Content-ID or FALSE if not found Return type: string Sets and returns an attachment’s Content-ID, which enables your to embed an inline (picture) attachment into HTML. First parameter must be the already attached file name. $filename = '/img/photo1.jpg'; $this->email->attach($filename); foreach ($list as $address) { $this->email->to($address); $cid

CI_Security::xss_clean()

xss_clean($str[, $is_image = FALSE]) Parameters: $str (mixed) – Input string or an array of strings Returns: XSS-clean data Return type: mixed Tries to remove XSS exploits from the input data and returns the cleaned string. If the optional second parameter is set to true, it will return boolean TRUE if the image is safe to use and FALSE if malicious data was detected in it.

get_instance()

get_instance() Returns: Reference to your controller’s instance Return type: CI_Controller

form_textarea()

form_textarea([$data = ''[, $value = ''[, $extra = '']]]) Parameters: $data (array) – Field attributes data $value (string) – Field value $extra (mixed) – Extra attributes to be added to the tag either as an array or a literal string Returns: An HTML textarea tag Return type: string This function is identical in all respects to the form_input() function above except that it generates a “textarea” type. Note Instead of the maxlength and size attributes in the above example, you wi

CI_URI::total_rsegments()

total_rsegments() Returns: Count of routed URI segments Return type: int This method is identical to total_segments(), except that it returns the total number of segments in your re-routed URI in the event you are using CodeIgniter’s URI Routing feature.

CI_Encrypt::encode_from_legacy()

encode_from_legacy($string[, $legacy_mode = MCRYPT_MODE_ECB[, $key = '']]) Parameters: $string (string) – String to encrypt $legacy_mode (int) – Valid PHP MCrypt cipher constant $key (string) – Encryption key Returns: Newly encrypted string Return type: string Enables you to re-encode data that was originally encrypted with CodeIgniter 1.x to be compatible with the Encrypt library in CodeIgniter 2.x. It is only necessary to use this method if you have encrypted data stored permane

valid_email()

valid_email($email) Parameters: $email (string) – E-mail address Returns: TRUE if a valid email is supplied, FALSE otherwise Return type: bool Checks if the input is a correctly formatted e-mail address. Note that is doesn’t actually prove that the address will be able recieve mail, but simply that it is a validly formed address. Example: if (valid_email('[email protected]')) { echo 'email is valid'; } else { echo 'email is not valid'; } Note All that this function