Page 1 of 1

PHP header location time?

Posted: Mon Mar 17, 2008 3:19 pm
by JAB Creations
I know I've seen it somewhere, setting how long PHP should wait until it executes the following code...

Code: Select all

header ("Location: http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);

Re: PHP header location time?

Posted: Mon Mar 17, 2008 3:34 pm
by Zoxive
JAB Creations wrote:I know I've seen it somewhere, setting how long PHP should wait until it executes the following code...

Code: Select all

header ("Location: http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
If you sleep() server side the page will be blank with nothing.

If you want to show html you will need a meta redirect. (Which is client side)

Re: PHP header location time?

Posted: Mon Mar 17, 2008 4:11 pm
by JAB Creations
If it isn't related to header location then it's :offtopic:

http://us3.php.net/header
I know it's directly related to location but it's not documented on php.net!

Re: PHP header location time?

Posted: Mon Mar 17, 2008 4:21 pm
by JAB Creations
It looks sort of like this though this isn't waiting the ten seconds...

Code: Select all

header ("Location: http://localhost/", 10);

Re: PHP header location time?

Posted: Mon Mar 17, 2008 4:36 pm
by RobertGonzalez
Have you tried:

Code: Select all

<?php
// 5 second refresh rate
header('Refresh: 5; url=http://' . $_SERVER['HTTP_HOST'] . basename(__FILE__));
exit;
?>
Don't know if it will work but it is worth a shot.

Re: PHP header location time?

Posted: Mon Mar 17, 2008 8:21 pm
by JAB Creations
It works but it's not the answer to my question.

Code: Select all

header("refresh: 5; url='http://localhost/'");

Re: PHP header location time?

Posted: Mon Mar 17, 2008 9:40 pm
by Zoxive
JAB Creations wrote:It works but it's not the answer to my question.
I don't see a question. Other then the original post name, which seems to have been answered.

Re: PHP header location time?

Posted: Mon Mar 17, 2008 9:43 pm
by JAB Creations
A header location with a time set in seconds before the page redirects. The browser obviously receives the commend via headers and does not redirect the page for X number of seconds.

Re: PHP header location time?

Posted: Mon Mar 17, 2008 9:49 pm
by Zoxive
JAB Creations wrote:A header location with a time set in seconds before the page redirects. The browser obviously receives the commend via headers and does not redirect the page for X number of seconds.
Read my first post, and/or give us an example of a website which already does this.

How does it obviously get it via headers? If there is a delay there has to be something sent, and then a wait. This is done on the forum here, when you post messages via meta-refresh.

Re: PHP header location time?

Posted: Mon Mar 17, 2008 9:52 pm
by JAB Creations
All I know is that it looks something like this...

Code: Select all

header ("Location: http://localhost/", 10);
I've used it myself and it's very minimal code.

Re: PHP header location time?

Posted: Mon Mar 17, 2008 9:54 pm
by RobertGonzalez
Are you sure you were using a native PHP function?

Re: PHP header location time?

Posted: Mon Mar 17, 2008 10:12 pm
by JAB Creations
I don't recall where I got it from but the code looked like that. I used Advanced Find & Replace to look through all the files in my web folder to see if I had a copy of it with the timer though I couldn't find it. I remember using it though at one point.

Re: PHP header location time?

Posted: Mon Mar 17, 2008 11:23 pm
by RobertGonzalez
I was only asking because the behavior of the header() function does not work the way your example works. If the syntax is as you say it was then I would guess that there was another function taking the params and doing something with them.

Re: PHP header location time?

Posted: Mon Mar 17, 2008 11:54 pm
by Christopher
Sounds more like the "meta-equiv" tag that goes in <head> to me. That has a time with it.