PHP timed execution problem, get parameter problem after sleep

Source: Internet
Author: User
Keywords Php
Tags sleep function
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;
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.