Search code examples
phpmethodssendnotify

how to make a method to notify time past in PHP


I need a method to notify my application that one minute has elapsed in php. This method is of type void

I try it:

public function minutes() : void {

    ini_set('max_execution_time', 60);

    $i = 0;

    while ( $i < 60 ){
        $i++;
        sleep(1);
    }

Solution

  • Try this

    set_time_limit(0);
    ob_implicit_flush();
    
    public function minutes() : void {
    
     $i = 0;
    
     while ( $i < 5 /*change here whatever you want */ ){
            sleep(60);
            $i++;
            echo "$i minute(s) has passed.";
     }
    }