Re: RE: [PHP] How to ASP style Response.Redirect
| From: | Frank M. Kromann | Date: | Tue, 03 Oct 2000 19:46:06 +0000 |
| Subject: | Re: RE: [PHP] How to ASP style Response.Redirect | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-18468@lists.php.net to get a copy of this message | ||
>> Is there a way to do an ASP style response.redirect from
>> within a PHP script. I know I can use
>>
>> header("Location: somepage.html");
>>
>> but it gives the error headers have already been sent unless
>> I put the above line at the beginning of the page. PHP seems
>> pretty cool I'm surprised I can't find a way just to do a
>> redirect as my script is running.
>>
PHP sends all printed information to the web server and if you send a header after you have started
sending the document the server would not know what to do.
I think ASP caches all information until a Response.End. You would not be able to send a
Respons.Redirect af a Respons End !
You can either collect the entire document before sending it to the web server, this way you can
decide as you go if you need to redirect. You could also use a javascript
location.href=''; this way it is the browser doing the redirect.
- Frank