PHP怎么实现定时提醒功能?
phpcn_u274
phpcn_u274 2017-02-10 13:14:13
0
2
961

比如想要实现这么一个功能:在用户生日当天或者提前几天就能自动给用户发送一条信息。

或者在会员到期日期的前两三天自动就能给用户发送信息,如何才能用PHP语言来自动化实现这么一个功能呢?

phpcn_u274
phpcn_u274

reply all(2)
数据分析师

How to implement the scheduled reminder function in PHP? -PHP Chinese website Q&A-How to implement the scheduled reminder function in PHP? -PHP Chinese website Q&A

Let’s take a look and learn.

阿神

推荐使用workerman 或 swoole

//获取定时任务的配置
$timing_task=api_base::load_config('zip_remove');
if($timing_task['is_remove']){
    
    \Man\Core\Lib\Task::add($timing_task['time_interval'], function(){
        $zip_remove=api_base::load_sys_class('zpi_file');
        
        $zip_xml_config=api_base::load_config('zip_xml');
        $zip_path=$zip_xml_config['BCP_PATH'][0]['val'];
        $timing_task=api_base::load_config('zip_remove');
        if(!empty($timing_task['delete_zip_time'])){
            if(date('H:i',time())==$timing_task['delete_zip_time']){
                $zip_remove=new zpi_file();
                $zip_remove->remove_zip_file($zip_path);
            }
        }else{
            $zip_remove=new zpi_file();
            $zip_remove->remove_zip_file($zip_path);
        }
            
    });
}

workerman 大概就是这种语法

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template