Refresh page with PHP function header()

Posted by Shek on December 25, 2008 under PHP | Be the First to Comment | Total View: 59,540 views

Editor’s note: In my past post Redirect page using PHP function header(), I talked about how to redirect page with header() function. To refresh a page, by using the same function and redirect to the page to itself, then it has the refresh effect.

In order to do so, we have to add another attribute into the function “second”, the way to do is like this:

<?php
header( 'refresh: SECOND; url= ADDRESS' );
?>

Replace SECOND with the number of second.
Replace ADDRESS with the web address of the page.

Here are a few examples:

To redirect to a page after 1 second:

<?php
header( 'refresh: 1; url=http://www.phpsuperblog.com' );
?>

To redirect to a page after 10 second:

<?php
header( 'refresh: 10; url=http://www.phpsuperblog.com' );
?>

To redirect to a page after 60 second:

<?php
header( 'refresh: 60; url=http://www.phpsuperblog.com' );
?>

Place the PHP code in the first line of the HTML head section.

Not what you want? Try a Search

Add A Comment

*