Author: Awais Farooq
-
Benchmarking
Setting Benchmark Points If you want to measure the time taken to execute a set of lines or memory usage, you can calculate it by using Benchmarking points in CodeIgniter. There is a separate “Benchmarking” class for this purpose in CodeIgniter. This class is loaded automatically; you do not have to load it. It can…
-
Application Profiling
When building a web application, we are very much concerned about the performance of the website in terms of how much time the controller took to execute and how much memory is used. Not only the performance, but we also need to see the insights of data like POST data, data of database queries, session…
-
Page Redirection
While building web application, we often need to redirect the user from one page to another page. CodeIgniter makes this job easy for us. The redirect() function is used for this purpose. Syntax redirect($uri = ”, $method = ‘auto’, $code = NULL) Parameters $uri (string) − URI string$method (string) − Redirect method (‘auto’, ‘location’ or ‘refresh’)$code (string) − HTTP Response…
-
Page Caching
Caching a page will improve the page load speed. If the page is cached, then it will be stored in its fully rendered state. Next time, when the server gets a request for the cached page, it will be directly sent to the requested browser. Cached files are stored in application/cache folder. Caching can be enabled on…
-
Common Functions
CodeIgniter library functions and helper functions need to be initialized before they are used but there are some common functions, which do not need to be initialized. These common functions and their descriptions are given below. Syntax is_php($version) Parameters $version (string) − Version number Return TRUE if the running PHP version is at least the one…
-
Cookie Management
Cookie is a small piece of data sent from web server to store on client’s computer. CodeIgniter has one helper called “Cookie Helper” for cookie management. Syntax set_cookie($name[, $value = ”[, $expire = ”[, $domain = ”[, $path = ‘/’[, $prefix = ”[, $secure = FALSE[, $httponly = FALSE]]]]]]]]) Parameters $name (mixed) − Cookie name or associative array of all of the…
-
Tempdata
In some situations, where you want to remove data stored in session after some specific time-period, this can be done using tempdata functionality in CodeIgniter. Add Tempdata To add data as tempdata, we have to use mark_as_tempdata() function. This function takes two argument items or items to be stored as tempdata and the expiration time for those items are as shown below.…
-
Flashdata
While building web application, we need to store some data for only one time and after that we want to remove that data. For example, to display some error message or information message. In PHP, we have to do it manually but CodeIgniter has made this job simple for us. In CodeIgniter, flashdata will only…
-
Session Management
When building websites, we often need to track user’s activity and state and for this purpose, we have to use session. CodeIgniter has session class for this purpose. Initializing a Session Sessions data are available globally through the site but to use those data we first need to initialize the session. We can do that by…
-
Form Validation
Validation is an important process while building web application. It ensures that the data that we are getting is proper and valid to store or process. CodeIgniter has made this task very easy. Let us understand this process with a simple example. Example Create a view file myform.php and save the below code it in application/views/myform.php. This page…