Refresh a page using PHP
How can I refresh a page using PHP periodically? If I can not do it by PHP, what is the best recommended scenario?
You can do it with PHP:
It refreshes your current page, and if you need to redirect it to another page, use following:
Read more… Read less…
You sure can refresh a page periodically using PHP:
<?php header("refresh: 3;"); ?>
This will refresh the page every three seconds.
I've found two ways to refresh PHP content:
1. Using the HTML
echo("<meta http-equiv='refresh' content='1'>"); //Refresh by HTTP 'meta'
2. Using PHP refresh rate:
$delay = 0; // Where 0 is an example of a time delay. You can use 5 for 5 seconds, for example! header("Refresh: $delay;");
Besides all the PHP ways to refresh a page, the page will also be refreshed with the following HTML meta tag:
<meta http-equiv="refresh" content="5">
See Meta refresh - "automatically refresh the current web page or frame after a given time interval"
You can set the time within the
header('Location: .'); seems to refresh the page in Chrome, Firefox, Edge, and Internet Explorer 11.