Re: Header Processing




Call Me Tom schreef:

Hi Tom,

I was looking at an application with the following code snippet:

ob_start();
session_name('foo');
session_start();
if (!$_SESSION['bar']) { header("Location: http://"; . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/index.php");
ob_end_clean();
exit();
}

I am under the impression that the "header" redirection is immediate.

That is wrong.
This is not like, for example ASP/VB's Response.Redirect.
header() function in PHP does excact what it says and nothing more: Setting a header.

Am I correct or will the 'ob_end_clean()' and 'exit()' actually
process.

They will be processed.


Tom

Bottomline: If you need a 'redirect' via header("Location...") always call exit after that, or the script will merely run on untill it ends.

Regards,
Erwin Moller

--
============================
Erwin Moller
Now dropping all postings from googlegroups.
Why? http://improve-usenet.org/
============================
.



Relevant Pages

  • Re: Header Processing
    ... Erwin Moller wrote: ... I am under the impression that the "header" redirection is immediate. ... The script will continue until the redirect actually takes place. ...
    (comp.lang.php)
  • Re: header???
    ... 07 maj 2009 was a sad day cause Erwin Moller ... In case you are talking about the Location header: ... Mind the exit; ... goto kinda guy ...
    (php.general)
  • Re: header???
    ... 03 maj 2009 was a sad day cause Erwin Moller ... Why should outputting a header reload a page? ... In case you are talking about the Location header: ... Mind the exit; ...
    (php.general)
  • Re: Header Processing
    ... Erwin Moller wrote: ... I am under the impression that the "header" redirection is immediate. ... The script will continue until the redirect actually takes place. ...
    (comp.lang.php)
  • Re: easiest way to create a graph?
    ... Erwin Moller ... > If you think your imagescript is producing errors, change the header ... > to text/html, ...
    (comp.lang.php)