Thursday, 4 December 2014

How to find execution time for a script in PHP

if your are a PHP dev and you execute php scripts to test time taken, the following code can help you

microtime — Return current Unix timestamp with microseconds

//Start time
$time_start = microtime(true);

// Sleep for 1 sec

//Execution of your script

//End time
$time_end = microtime(true);

//Time taken
$time = $time_end - $time_start;

echo "Time taken is $time seconds\n";


Hope this will be useful in your application

Tuesday, 18 February 2014

How to add assets in CodeIgniter

When you are creating a Web Application with CI, you work with assets

you can create a "assets" folder in the root folder

To activate it

Step 1: Create Application Helper

function asset_url(){
   return base_url().'assets/';

Step 2: application/config/autoload.php:
$autoload['helper'] = array('url','utility');

After this you can very well use asset_url(); with in your application

How to remove index.php from url in code igniter

Create a .htaccess file in root directory and

Copy paste this code
RewriteEngine on

RewriteCond $1 !^(index\.php|assets|robots\.txt)

RewriteRule ^(.*)$ index.php/$1 [L]
where assets is the folder in the root directly containing all your assets Ref