Take the 2-minute tour ×

Here is my try:


As you have seen,there is no control over "3 seconds",how to make it take effect in 3 seconds?

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

This should work, in PHP:

header('Refresh: 3; url=index.php');
share|improve this answer
how is this supported by different browsers? –  omg Jul 1 '09 at 12:09
AFAIK, it's supported by all major browsers. –  George Claghorn Jul 1 '09 at 12:27
Just note that this code has to come before any other php code on the page. –  George Claghorn Jul 1 '09 at 12:38
add comment

The easiest way to do this is to use a meta redirect or a javascript redirect. Saying as how you are serving text/html, you can echo either of these to the browser.

<meta http-equiv="refresh" content="3;URL=/newpage.php">


window.setTimeout(function() { window.location = '/newpage.php' }, 3000);

Edit: According to the Wikipedia page on URL redirection you can send the Refresh header directly to the browser from PHP. No clue on how well browsers support this though.

header('Refresh: 3; url=/newpage.php');
share|improve this answer
+1 ............... –  Aiden Bell Jun 30 '09 at 20:11
I remember seeing a PHP function that would output both. Don't really need to go hunt it down - the Asker could implement that. –  Jonathan Sampson Jun 30 '09 at 20:11
I think your parameters are mixed up on the setTimeout... –  Jonathan Sampson Jun 30 '09 at 20:13
@Jonathan: Thanks, fixed. –  tj111 Jun 30 '09 at 20:18
no,i need it to be done in pure php,not html –  omg Jul 1 '09 at 12:09
add comment

You could take advantage of the refresh meta tag, like this:

    <title>redirect page</title> 
    <META http-equiv="refresh" content="5;URL=http://www.newurl.com"> 
<body bgcolor="#ffffff"> 
    The contents you are looking for have moved. 
share|improve this answer
add comment

Your Answer


