Let's take a look at the example.
Example
The code is as follows: |
Copy code |
Function geturl ($ url, $ userinfo, $ header) { $ Ch = curl_init (); $ Timeout = 1; Curl_setopt ($ ch, CURLOPT_URL, "$ url "); Curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ header ); Curl_setopt ($ ch, CURLOPT_REFERER, "http://www.111cn.net /"); Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 ); Curl_setopt ($ ch, CURLOPT_USERAGENT, "$ userinfo "); Curl_setopt ($ ch, CURLOPT_CONNECTTIMEOUT, $ timeout ); $ Contents = curl_exec ($ ch ); Curl_close ($ ch ); Return $ contents; } |
Execute for a while to discover
Fatal error: Maximum execution time of 30 seconds exceeded in D: phpAppServwww360dtest. php on line 3
Add
The code is as follows: |
Copy code |
Set_time_limit (0); // Set the timeout value. |
In this way, there is no problem. Next I will briefly introduce the set_time_limit details.
Set_time_limit-maximum execution Time: set_time_limit (PH3, PHP4) set_time_limit-maximum execution time syntax: void set_time_limit (int seconds) description: sets the number of seconds a program can run, if the time limit is reached, the program will return an error.
The default limit time is 30 seconds. The value of max_execution_time is defined in the structure File (php3.ini in PHP3, php in PHP4 and PHP5. ini). If the number of seconds is set to 0, there is no time limit.
When you call this function, set_time_limit () calculates the maximum execution time from scratch. That is, if the maximum execution time is 30 seconds, however, if it takes 25 seconds to execute the program before calling set_time_limit (20), the maximum program execution time will be 45 seconds.
Some friends said they could modify apache % C5 % E4 % D6 % C3/"target =" _ blank "> apache configuration, but I didn't test it.
1. Modify APACHE settings and find a parameter in PHP. INI:
Max_execution_time
Increase the subsequent values and restart the APACHE service (centos: service httpd restart.
For example
Max_execution_time= 600