首先,我想给你的什么,我试图做的基本思想:PHP结束脚本执行全自动
我试图做一个免费的网络托管服务做一些工作对我来说。我创建了一个php页面和MySQL数据库。后面我的PHP页面的基本想法是我有$关机状态while循环和while循环中的一些反跟踪代码是否正在运行或不
<?php
/*
Connect to database etc. etc
*/
$shutdown = false;
// Main loop
while (!$shutdown)
{
// Check for user shutdown request
$strq = "SELECT * FROM TB_Shutdown;";
$result = mysql_query($strq);
$row = mysql_fetch_array($result);
if ($row[0] == "true")
{
$shutdown = true; // I know this statement is useless but nevermind
break;
}
//Increase counter
$strq = "SELECT * FROM TB_Counter;";
$result = mysql_query($strq);
$row = mysql_fetch_array($result);
if (intval($row[0]) == 60)
{
// Reset counter
$strq = "UPDATE TB_Counter SET value = 0";
$result = mysql_query($strq);
/*
I have some code to do some works at here its not important just curl stuff
*/
else
{
// Increase counter
$strq = "UPDATE TB_Counter SET value = " . (intval($row[0]) + 1);
$result = mysql_query($strq);
}
/*
I have some code to do some works at here its not important just curl stuff
*/
// Sleep
sleep(1);
}
?>
而且我有一个check.php返回我来自TB_Counter的值。
的问题是:我跟踪TB_Counter表中的每一秒。一段时间后停止。如果我关闭了我的浏览器(我在php循环页面中调用了我的主浏览器),它会在2分钟后停止。如果不在5-7分钟后,浏览器和循环停止时出现“连接已重置”的错误。
我应该怎么做才能让我的循环是永恒的?
好吧我试图设置它 set_time_limit(0);但它不起作用。也许服务器不允许我设置时间限制?在设置它来检查我是否被允许进行更改后,是否有办法获取time_limit? – user1492948
是的,现在尝试运行脚本,有什么区别? –
看到我的编辑对不起! – user1492948