Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #2478

Re: header() not being honored?

Message-Id <2010861.x15VjT5ukT@PointedEars.de>
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2011-07-10 08:47 +0200
Subject Re: header() not being honored?
Newsgroups comp.lang.php
References <iv6v01$qou$1@speranza.aioe.org> <4e1851ab$0$14255$ba620e4c@news.skynet.be>
Followup-To comp.lang.php

Followups directed to: comp.lang.php

Show all headers | View raw


Andre wrote:

> Le Fri, 08 Jul 2011 08:57:39 -0400, Billy Mays a écrit :
>> Am I misunderstanding how to use the header function?  Is there another
>> way to see whats going on?  Unfortunately, I'm in a shared hosting
>> environment, PHP: 4.4.9
> 
> I alreay had the problem.
> If you attempt to print anything BEFORE the call to header, it skip.

True.

> But any blank line could cause the troube, I had once a blank line in a
> 'required file', something like:
> 
> Debug = 1;

AFAIK this is not PHP code.

  define('Debug', 1);

or

  $Debug = 1;

would be.
 
> ?>
> 
> The blank line between debug and ?> shoule also be removed.

Nonsense.  Blank lines in the *generated* output matter, as the response 
message body is considered to have started then.  What is between `<?php' 
and `?>' is not sent to the standard output as-is, but its parsing result 
is.  The parser ignores all whitespace unless it separates tokens or is 
within a string literal (single-quoted, double-quoted, here-doc, or here-
string).

<http://www.php.net/manual/en/tutorial.firstpage.php>

> I still have trouble in a last script, so if someone has more on this..

You need to look *before* `<?php' and *after* `?>' for unwanted whitespace 
and Byte Order Marks (BOMs), and *between* those delimiters for *statements* 
that *generate* it (an empty line is not).  For example, a common mistake is 
to store a PHP script encoded in a UTF and attach a BOM (here for UTF-8, 
where it is unnecessary and unwise anyway):

<EF><BB><BF><?php
  header('...');
?>

A way to find out is

  wget -O - http://example.example/index.php > /tmp/out.php
  hexedit /tmp/out.php


PointedEars
-- 
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
  -- Richard Cornford, cljs, <f806at$ail$1$8300dec7@news.demon.co.uk>

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

header() not being honored? Billy Mays <noway@nohow.com> - 2011-07-08 08:57 -0400
  Re: header() not being honored? Jerry Stuckle <jstucklex@attglobal.net> - 2011-07-08 14:11 -0400
  Re: header() not being honored? crankypuss <no@email.thanks> - 2011-07-09 04:25 -0600
  Re: header() not being honored? Andre <pas@pourmois.be> - 2011-07-09 13:03 +0000
    Re: header() not being honored? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-07-10 08:47 +0200
      Re: header() not being honored? Andre <pas@pourmois.be> - 2011-07-10 14:18 +0000

csiph-web