Timed execution is required in the project, but timing is a variable parameter, not a fixed
Start thinking about using crontab, but the time parameter is not customizable, and you need to get a pass-through ID to execute the sleep program
Using the Sleep function in PHP, you encounter a problem where a GET or post parameter before sleep is not available after sleep.
ignore_user_abort(); //即使Client断开(如关掉浏览器),PHP脚本也可以继续执行. set_time_limit(0); // 执行时间为无限制,php默认执行时间是30秒,可以让程序无限制的执行下去 $interval=$_GET['interval']; // 接收$_GET参数$id = $_GET['id']; //这里是请求触发的时候传递过来的ID,在sleep后需要用到flush(); sleep($interval); // 按设置的时间等待执行 */ /*** sleep后需要用到上面的$id,来执行其他程序,测试后发现$id获取不到。为空**/
Have you known the great God? or provide some other ideas, thank you!
Reply content:
Timed execution is required in the project, but timing is a variable parameter, not a fixed
Start thinking about using crontab, but the time parameter is not customizable, and you need to get a pass-through ID to execute the sleep program
Using the Sleep function in PHP, you encounter a problem where a GET or post parameter before sleep is not available after sleep.
ignore_user_abort(); //即使Client断开(如关掉浏览器),PHP脚本也可以继续执行. set_time_limit(0); // 执行时间为无限制,php默认执行时间是30秒,可以让程序无限制的执行下去 $interval=$_GET['interval']; // 接收$_GET参数$id = $_GET['id']; //这里是请求触发的时候传递过来的ID,在sleep后需要用到flush(); sleep($interval); // 按设置的时间等待执行 */ /*** sleep后需要用到上面的$id,来执行其他程序,测试后发现$id获取不到。为空**/
Have you known the great God? or provide some other ideas, thank you!
Comment out the flush
Tests can be performed
ignore_user_abort(); //即使Client断开(如关掉浏览器),PHP脚本也可以继续执行. set_time_limit(0); // 执行时间为无限制,php默认执行时间是30秒,可以让程序无限制的执行下去 // params$interval=$_GET['interval']; // 接收$_GET参数$id = $_GET['id']; //这里是请求触发的时候传递过来的ID,在sleep后需要用到flush(); sleep($interval);echo $id;