Php 如何让网页停止长时间运行的进程
我有以下代码,它运行一个永远运行(直到终止)的进程,并显示结果(使用下面的tail-F作为示例):Php 如何让网页停止长时间运行的进程,php,Php,我有以下代码,它运行一个永远运行(直到终止)的进程,并显示结果(使用下面的tail-F作为示例): 这类工作,我的进程运行,但它继续运行,当我停止加载页面,关闭标签,等等 当我不显示页面时,是否有一些机制可以用来停止进程?我肯定有,但不清楚。。。。 ... header("Content-type:text/html");// start the content serving echo("\n"); // connection with the browser while(!feof($h
这类工作,我的进程运行,但它继续运行,当我停止加载页面,关闭标签,等等
当我不显示页面时,是否有一些机制可以用来停止进程?我肯定有,但不清楚。。。。
...
header("Content-type:text/html");// start the content serving
echo("\n"); // connection with the browser
while(!feof($handle)) {
$buffer = fgets($handle);
echo $buffer . "<br />";
ob_flush();
flush();
sleep(1);
if (connection_status()!=0){ // check the connection
die; // or whatever you want to stop the work
}
}
标题(“内容类型:text/html”);//启动内容服务
回声(“\n”);//与浏览器的连接
而(!feof($handle)){
$buffer=fgets($handle);
echo$buffer。“
”;
ob_flush();
冲洗();
睡眠(1);
如果(连接状态()!=0){//请检查连接
死;//或者你想停止工作的任何东西
}
}
…尝试或可能是在循环中添加或的检查
...
header("Content-type:text/html");// start the content serving
echo("\n"); // connection with the browser
while(!feof($handle)) {
$buffer = fgets($handle);
echo $buffer . "<br />";
ob_flush();
flush();
sleep(1);
if (connection_status()!=0){ // check the connection
die; // or whatever you want to stop the work
}
}