V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
a7898585
V2EX  ›  Linux

求教,php循环执行问题

  •  
  •   a7898585 · 2014-01-22 15:38:24 +08:00 · 2817 次点击
    这是一个创建于 3718 天前的主题,其中的信息可能已经有所发展或是发生改变。
    通过while或者if函数设置的,对没达到要求的不断循环执行
    比如
    $i=1;
    while($i<10000)
    {
    echo ”次数为“ . $i;
    $i++;
    }
    那么我在打开php页面,在页面完成并跳出 结果之前关闭了浏览器,那么后台还会执行吗?
    9 条回复    1970-01-01 08:00:00 +08:00
    shiny
        1
    shiny  
       2014-01-22 15:40:57 +08:00
    请查看相关函数: ignore_user_abort、fastcgi_finish_request
    RobinFai
        2
    RobinFai  
       2014-01-22 15:41:37 +08:00
    修改输出为更新文件内容,然后你就知道了。
    kran
        3
    kran  
       2014-01-22 15:53:19 +08:00
    执行
    a7898585
        4
    a7898585  
    OP
       2014-01-22 15:59:55 +08:00
    @RobinFai
    <?php
    $i=1;
    while($i<999999)
    {
    $i++;
    if ($i=999998)
    {
    $file=fopen("word.txt","a");
    }
    }
    ?>
    为毛执行不下去。。。。
    Fatal error: Maximum execution time of 30 seconds exceeded in /home2/a7898585/public_html/woaixiaofeifei.com/ceshi/1.php on line 8
    Jat001
        5
    Jat001  
       2014-01-22 16:03:54 +08:00
    @a7898585 你设置了超时 30 秒……
    raincious
        6
    raincious  
       2014-01-22 16:06:38 +08:00
    @a7898585 因为超过了最大执行实践,被强制终止了。
    msg7086
        7
    msg7086  
       2014-01-23 05:55:01 +08:00
    @a7898585 因为$i 永远是999998。

    证据: $i = 999998
    picasso250
        8
    picasso250  
       2014-01-23 14:58:17 +08:00
    笑死了
    RobinFai
        9
    RobinFai  
       2014-03-05 10:36:47 +08:00
    题主在卖萌
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1481 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 17:22 · PVG 01:22 · LAX 10:22 · JFK 13:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.