完成加载后页面刷新,加起来变量

时间:2011-08-30 23:26:03

标签: php loops refresh refresher

$test = $_GET['nr'];
    $class = new class;
    echo $class->function($test);

我希望$test在完全加载页面后增加。

问题是,我不知道怎么回事。循环$ test通常会显示很多错误。像function cannot be declared again我有相同的功能名称和不同的功能。这是很长的代码。

任何人都知道我该怎么做? 感谢。

编辑:

当页面完全加载时,我希望它将+ 1添加到$test,然后使用新变量刷新它。

我可以通过以下方式手动执行此操作:

$next = $test + 1;
    echo "<a href='/index.php?nr=". $next . "'>Next page</a>";

1 个答案:

答案 0 :(得分:2)

如果您将页面存储在字符串变量中并在最后输出,则可以进行元刷新:

$next = $test + 1;
echo "<meta http-equiv=\"refresh\" content=\"5; url=/index.php?nr=$next\">";

...将在加载完成后5秒刷新页面。

如果做不到这一点,你可以做一个简单的javascript刷新:

$next = $test + 1;
echo "<script type=\"text/javascript\">\nfunction reloadPage() {\nwindow.location.href = '/index.php?nr=$next';\n}\nsetTimeout(reloadPage,5000);\n</script>";
相关问题