PHP work notes: Perform PHP tasks offline

Source: Internet
Author: User

Directly on the code, the main function

Ignore_user_abort (TRUE);
This function ignores the terminal being closed (the Open Web page is closed), the back
GetFiles () This function is a custom function that performs the acquisition task, followed by the next path
Open the written page, close, after the discovery of the task can be completed, interested can try.
<?PHP//set ignore whether terminal window is closedIgnore_user_abort(true);Ini_set(' Max_execution_time ', ' 0 ');//Collect page functions, do not understand the implementation of Baidu Curl PHPfunctionGetFiles$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 an array of page paths to be collected$urls=Array(    ' http://www.cnblogs.com/jianqingwang/p/6373168.html ', ' http://www.cnblogs.com/jianqingwang/p/6148644.html ', ' Http://www.61916.com/news_view_2423.html ', ' http://blog.sina.com.cn/s/blog_8e326c350102w1ah.html ', ' HTTP// Www.w3school.com.cn/php/func_misc_ignore_user_abort.asp ', ' http://xinwen.eastday.com/a/170219205305597.html ', ' Http://society.huanqiu.com/article/2017-02/10162630.html?from=bdwz ', ' http://www.cankaoxiaoxi.com/roll10/bd/ 20170220/1699670.shtml ', ' http://news.china.com/socialgd/10000169/20170220/30266284.html ', ' http://news.k618.cn/ Society/201702/t20170220_10368740.html ', ' http://fj.qq.com/a/20170218/029521.htm ');//iterating through an arrayforeach($urls  as $key=$val) {GetFiles ($val,$key);}?>

PHP work notes: Perform PHP tasks offline

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.