duankanjian4642 2014-05-26 04:26
浏览 18
已采纳

PHP脚本如何不终止?

I'm on shared hosting and constantly get over process limit errors. Support said if traffic is low then it's because inefficient scripts are not terminated. Since I'm on a shared host and I only create the .php files, I don't really get how my scripts which only serve pages (that is they are called by Apache when a request coming in and they create and display the page) could not terminate.

Is it possible a script can linger on even if it's finished its job? Is there a way to make a script terminate other than exiting when end of file is reached?

My scripts are regular PHP scripts, they fetch data from the database, create the HTML and then exit. They do not do anything special.

  • 写回答

2条回答 默认 最新

  • duanchazhou6779 2014-05-26 04:32
    关注

    Your PHP Script is running in a Loop which creates the HTML.

    1. It total depends on how much records are coming out of your database.
    2. Their maybe some sort of leakage in your Query which is making it heavy on the Server.
    3. The loop will only end after it's done with it's JOB.

    Please paste some code so that we can investigate and help you out. At this time, this all I can say as mentioned above.

    You can track down how long does it take for the script to run

    <?php 
        /* Put this first thing before the loop begins */
        echo "Start " . date("Y-m-d H:i:s"); 
    ?>
    
    <?php 
        /* Put this at the end of your script */
        echo "End " . date("Y-m-d H:i:s"); 
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 蓝桥oj3931,请问我错在哪里
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染