Reputation: 379
$test = $_GET['nr'];
$class = new class;
echo $class->function($test);
I want $test
to increase after it have fully loaded the page.
The problem is, I don't know how. Looping $test normally will show me a lot of errors. like function cannot be declared again
I've have the same functions names with different functionality. 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.
I can do this manually by:
$next = $test + 1;
echo "<a href='/index.php?nr=". $next . "'>Next page</a>";
Upvotes: 0
Views: 1768
Reputation: 88657
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.
Failing that, you can do a simple javascript refresh:
$next = $test + 1;
echo "<script type=\"text/javascript\">\nfunction reloadPage() {\nwindow.location.href = '/index.php?nr=$next';\n}\nsetTimeout(reloadPage,5000);\n</script>";
Upvotes: 2