简体   繁体   English

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

[英]Page refresh after done loading, add up variable

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

I want $test to increase after it have fully loaded the page. 我希望$test在完全加载页面后增加。

The problem is, I don't know how. 问题是,我不知道怎么做。 Looping $test normally will show me a lot of errors. 循环$ test通常会显示很多错误。 like function cannot be declared again I've have the same functions names with different functionality. function cannot be declared again我有相同的函数名称具有不同的功能。 And it's pretty long code. 这是很长的代码。

Anyone have any idea how I can do this? 任何人都知道我该怎么做? Thanks. 谢谢。

EDIT: 编辑:

When the page is fully loaded, I want it to add + 1 to $test and then refresh it with the new variable. 当页面完全加载时,我希望它将$test 1添加到$test ,然后使用新变量刷新它。

I can do this manually by: 我可以通过以下方式手动完成:

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

If you are storing the page in a string variable and outputting at the end you can just do a meta refresh: 如果要将页面存储在字符串变量中并在最后输出,则只需执行元刷新:

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

...will refresh the page 5 seconds after loading completes. ...将在加载完成后5秒刷新页面。

Failing that, you can do a simple javascript refresh: 如果做不到这一点,你可以做一个简单的javascript刷新:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM