[thelist] Tip: whitespace in included PHP causes header() calls to fail
Matt Warden
mwarden at gmail.com
Thu Aug 18 19:37:33 CDT 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Ian Anderson wrote:
> In PHP, calls to header( "Location: whatever.php" ) were failing
> silently whenever an include file was used to validate the user's
> session data.
>
> I thought it was something I was doing with cookies or session_start()
> in my included file, but no...
>
> Turned out there was a space *after* the closing "?> " in the included
> file, which was getting written to the browser as unintentional output
> at the start of the HTML. Of course, calls affecting HTTP header will
> not work if output has already been written to the browser.
This is why you should never use the closing ?> in include files (it's
optional).
- --
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com
This email proudly and graciously contributes to entropy.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFDBSnNAQ0d4HGyPE8RAnI0AJwOC0opkUPqIAoNHJ712MUV73IqCgCfSwMv
P+tdBjZvyYvmhLh65eUpOxg=
=aKR+
-----END PGP SIGNATURE-----
More information about the thelist
mailing list