for循环后循环不抛出脚本

时间:2014-06-30 22:06:19

标签: php

我有用于循环的PHP脚本,它应该循环遍历代码然后退出,但这些没有发生,它一直循环直到我手动退出。

我的代码

<?php
session_start();
?>

<?php

ignore_user_abort(true);

for( $x=0; $x< 50; )

{

$_SESSION['timeout'] = time();

$st = $_SESSION['timeout'] + 1;

session_unset();

$_SESSION['timeout'] = time();

$st = $_SESSION['timeout'] + 1;

print_r("$st\n");

}

if(time() < $st)
{

file_put_contents('/tmp/phptest1234.txt', 'test');

}

?>

1 个答案:

答案 0 :(得分:0)

下面是无限循环。 $ x始终保持为0.

for( $x=0; $x< 50; )

你需要这样做:

for( $x=0; $x< 50; $x++)

php man "for"

相关问题