0

I am getting this error while running one script.

I know it's about execution time and i had went through all answers too but i want to display custom message when this error occurs so that site doesn't break.

How to handle that error as i have kept error display off on my live site so footer is not loaded due to this error which stops breaking my site?

http://whois.icann.org/en/lookup?name=google.com 

When you visit this site its displaying custom error message

Leistungsabfall
  • 6,368
  • 7
  • 33
  • 41
Aishwarya Taneja
  • 140
  • 1
  • 12

6 Answers6

0

you can exceed max execution time like this :

ini_set('max_execution_time', 300); //300 seconds = 5 minutes

Shahzad Barkati
  • 2,532
  • 6
  • 25
  • 33
Nero
  • 265
  • 1
  • 3
  • 12
  • I mentioned in question i know how to increase max_execution_time. I don't want to do so, instead i want to display custom message when its max_execution_time error is there. – Aishwarya Taneja Sep 29 '15 at 05:51
  • http://www.php.net/manual/en/function.set-error-handler.php#106061.this might help – Nero Sep 29 '15 at 06:00
0

You can always modify your php.ini file. There is a setting for maximum execution time.

Another way is to use ini_set function.

Another way is to put the max execution time in your htaccess file.

EDIT:

The max execution time is not an error and therefore not catchable.

Please check out this: http://stackoverflow.com/questions/6861033/how-to-catch-the-fatal-error-maximum-execution-time-of-30-seconds-exceeded-in-p

Finally, there is always scope of fixing the scripts and putting lengthy processes into a queue.

  • Finally, there is always scope of fixing the scripts and putting lengthy processes into a queue... means? how it can be helpful? – Aishwarya Taneja Sep 29 '15 at 05:53
  • You can always put long processes in queue like: third party access, video converter logic, emails firing etc everything in background. In queue server. So that your PHP execution can get finished quickly and you can then show a message to user to notify that some processes are still running on background. –  Sep 29 '15 at 05:57
0

You can try to add this line of code in the file first:

set_time_limit(0)
Marser
  • 23
  • 3
0

You can either increase the maximum execution time by using set_time_limit() or by setting max_execution_time in the php.ini. Also by setting set_time_limit to 0 you can remove the limit for exceution time.

And if you are using linux you can try with the function register_shutdown_function.This function will be called when the execution time limit is reached.

dhi_m
  • 1,235
  • 12
  • 21
-1

change below configuration in php.ini

max_execution_time = 600; 
max_input_time = 120; 
max_input_nesting_level = 64;
memory_limit = 128M;
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
-1
ini_set('memory_limit', '-1');
ini_set('max_execution_time', '10000');

at the first line of your php code

Bhawin Parkeria
  • 51
  • 2
  • 10