PHP work notes: Execute php tasks offline and php tasks offline
Code directly, main functions
Ignore_user_abort (true );
This function ignores that the terminal is closed (the opened webpage is closed ).
Getfiles () is the custom function used to execute the collection task.
Open the prepared page and close it. All tasks can be executed later. If you are interested, try again.
<? Php // set whether to disable the terminal window ignore_user_abort (true); ini_set ('max _ execution_time ', '0'); // collect page functions, you cannot understand how to execute Baidu curl phpfunction getfiles ($ url, $ name) {$ name = $ name. ". txt "; $ ch = curl_init (" $ url "); $ fp = fopen (" $ name "," w "); curl_setopt ($ ch, CURLOPT_FILE, $ fp ); curl_setopt ($ ch, CURLOPT_HEADER, 0); curl_exec ($ ch); curl_close ($ ch); fclose ($ fp); sleep (5); echo '<script> window. close (); </script> ';} // configure the page path array to be collected $ urls = ar Ray ('HTTP: // scheme, 'HTTP: // scheme, 'HTTP: // www.61916.com/news_view_2423.html', 'HTTP: // scheme, 'HTTP: // xinwen.eastday.com/a/170219205305597.html', 'HTTP: // society.huanqiu.com/article/2017-02/10162630.html? From = bdwz', 'HTTP: // scheme, 'HTTP: // fj.qq.com/a/20170218/029521.htm '); // traverse the array foreach ($ urls as $ key => $ val) {getfiles ($ val, $ key) ;}?>