PHP work notes: Execute php tasks offline and php tasks offline

Source: Internet
Author: User

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) ;}?>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.