How to Increase the PHP script execution time? I am using a csv processing code , when i tried to import the csv content to the table using the php script, it take too much time and after that a download pop of the executing scripts name is showing...I think this is due to execution time problem. How to fix this? Three ways we can solve this. : Scroll down for the solution. | |
Three ways we can solve this. 1) set_time_limit() function usage : void set_time_limit ( int $seconds ) Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php.ini. When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out. The maximum execution time, in seconds. If set to zero, no time limit is imposed. This function has no effect when PHP is running in safe mode. There is no workaround other than turning off safe mode or changing the time limit in the php.ini. code to check safe mode and try the function: <?php if( !ini_get('safe_mode') ){ set_time_limit(50); } ?> set_time_limit has another advantage, you can call it several times and it adds the time to the total script runtime. so you can use it in a loop and it doesn’t matter how many iterations you have, you set only the time per iteration. ########### ########### 2) ini_set() function string ini_set( string $varname , string $newvalue ) The php function ini_set sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending. Usage ini_set( "max_execution_time" , "55" ) ########### ########### 3) Modifying `max_execution_time' value in PHP configuration(php.ini) file This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser. This helps prevent poorly written scripts from tying up the server. The default setting is 30. When running PHP from the command line the default setting is 0. options 1 and 2 are using for temporarily purpose and will persist until the scripts execution completed ie, The configuration option will keep this new value during the script's execution, and will be restored at the script's ending. Option 3 is for permanent purpose. More info: http://php.net/manual/en/function.set-time-limit.php http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time |
Manually submitting website pages to google Usually google crawls website's in a scheduled manner, but some time you may want to tell google about your new page or an important content updation. Insuch cases you can use following methods. Submit URl tool, Sitemap re-submission tool or Fetch as Google tool Each option is explained below:
Comments
Post a Comment