Wednesday, May 25, 2011

Enhance PHP Memory LIMIT, Upload FILE LIMIT and EXECUTION TIME: PART - 3


In this part, we will learn about how to increase execution time in PHP.

Increase Script Execution Time PHP scripts are only allowed to be executed for a definite period of time, and when it reaches the time limit, it will stop and create the following error: "Fatal error: Maximum execution time of 30 seconds exceeded in yourscript.php" To allow your PHP script to run at a longer time, you'll need to increase the maximum execution time limit of PHP scripts using any of the following methods.

3.1. php.ini configuration - Locate the php.ini file used by your web server. You can use the phpinfo() PHP function to find it. - find and modify next parameter: max_execution_time = 45 Change the value (in second) or set to 0 for infinite time - restart Apache

3.2..htaccess configuration Edit (Create) the.htaccess file in the site root (public) directory or in the directory of your script and add the following line: php_value max_execution_time 45 Change the value (in second) or set to 0 for infinite time

3.3. Configuration in PHP scripts This is probably the best method as the setting applies only to the particular script, and would not allow other poorly written scripts to also consume and waste the system's resource. To do this, call the following function in your PHP script with the maximum execution time in second as the parameter: set_time_limit ( 300 ) You can use 0 as parameter for infinite execution time.


development, apps development india, php developer india