Home  >  Article  >  Backend Development  >  How to implement schedule reminder in php

How to implement schedule reminder in php

藏色散人
藏色散人Original
2021-12-29 09:52:412348browse

php method to implement schedule reminder: 1. Create a PHP sample file; 2. Get the configuration of the scheduled task, code such as "$timing_task=api_base::load_config('zip_remove');if($timing_task. ..){...}".

How to implement schedule reminder in php

#The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer.

How to implement schedule reminder in php? How to implement scheduled reminder function in PHP?

For example, if you want to implement such a function: you can automatically send a message to the user on the user's birthday or a few days in advance. Or you can automatically send information to users two or three days before the membership expiration date. How can you use PHP language to automatically implement such a function?

Implementation method:

It is recommended to use workerman or 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 is probably this syntax

Recommended learning:《PHP video tutorial

The above is the detailed content of How to implement schedule reminder in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn