time exceed in PHP ? Want to increase time?

407 Views Asked by At

I am trying to parsing HTML data from HTML file. I have a file which contains many links . I get those links and load them in file_get_contents($link) (I use simple_html_dom for all This stuff ) and want to find specific text in those link . It works great for three or five links after than I got fatal error: time exceeded 30 seconds in simple HTML Dom line 82 .

What are the problem I guessed ? Slow internet speed (that I can not increase) . PHP.INI file configuration Simplehtmldom configuration

What I tried but failed ?

I have edited max_execution_time to 0 and 300 but not worked after restart server (using local XAMPP server )

I also tried to edit simple_HTML_Dom.PHP but did not worked .

I do not know whether my server setting safe mode is on or not

Thank you , Actually we are group of college student trying to make a project.

2

There are 2 best solutions below

2
François Huppé On BEST ANSWER

I know you tried setting max_execution_time, but you can try setting it using ini_set directly in your PHP script:

ini_set('max_execution_time', 300);

Also try default_socket_timeout, this will change the default timeout of the file_get_contents function:

ini_set('default_socket_timeout', 300);
0
Sandhya Nair On

Making max_execution_time to 0 in PHP.ini is a bad idea this is because timeouts are essential for webserver. However, in order to facilitate long time consuming script, you may use ini_set('max_execution_time', 0) which temporarily sets the value for max_execution_time.

Having put the value in script, keeps the new value during the script's execution, and will be restored at the script's ending.