start a function after X minutes on a page with php [closed]

-3

For example:

I have a page that performs a function after 7 minutes on it.

This function will increase "+1" in a field of my database.

    
asked by anonymous 05.03.2018 / 15:45

1 answer

-1

This is called asynchronous processing . There are several ways to do this, the first:

<?php

// Seu codigo aqui...

// Aqui chama o script que será executado em 7 minutos
exec("php executarApos7Min.php");

// ...

RunAppsMin.php code

<?php
ignore_user_abort(true);
set_time_limit(0);

//Pausa
sleep(420);

// sua query que soma +1

Another way:

$socketCon = fsockopen($host, 80, $errno, $errstr, 10);
if($socketCon) {   
   $socketDados = "GET www.meuserver.com.br/executarApos7Min.php HTTP 1.1\r\nHost: $host\r\nConnection: Close\r\n\r\n";      
   fwrite($socketCon, $socketDados); 
   fclose($socketConexao);
}
    
05.03.2018 / 16:36