By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,967 Members | 1,687 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,967 IT Pros & Developers. It's quick & easy.

header questions

P: n/a
I'm having some trouble wrapping my mind around header(), I'm used to
just printing the header and leaving a blank line.

Does php ignore whitespace before a header:

<?php

// no output here
?>

just whitespace, are the line feeds ignored?

<?php
header(...)...

Also, I take it that we can have multiple header functions. If I now
echo something or just have embedded html, I take that php inserts a
blank line and the header is finished?

Why can't I just echo the headers and not use header?

Jeff
Sep 28 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Jeff wrote:
I'm having some trouble wrapping my mind around header(), I'm used to
just printing the header and leaving a blank line.

Does php ignore whitespace before a header:

<?php

// no output here
?>

just whitespace, are the line feeds ignored?
Yes, PHP ignores whitespace.
<?php
header(...)...

Also, I take it that we can have multiple header functions. If I now
echo something or just have embedded html, I take that php inserts a
blank line and the header is finished?
No, PHP does not insert a blank line. It inserts whatever you echo.
However, ANY output causes the headers to be sent and the data portion
to begin.
Why can't I just echo the headers and not use header?

Jeff
Because headers are headers and all the rest is data. Two entirely
different things.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 28 '08 #2

P: n/a
"Jeff" <jeff@spam_me_not.comschreef in bericht
news:Pd******************************@earthlink.co m...
I'm having some trouble wrapping my mind around header(), I'm used to
just printing the header and leaving a blank line.

Does php ignore whitespace before a header:

<?php

// no output here
?>

just whitespace, are the line feeds ignored?

<?php
header(...)...

Be careful.

This does contain output between the two php lines which is not ignored.
---snip---
<?php $a=1; ?>

<?php header('whatever'); ?>
---snip---

The following is OK:
---snip---
<?php $a=1; ?>
<?php header('whatever'); ?>
---snip---

Sep 28 '08 #3

P: n/a
mijn naam wrote:
"Jeff" <jeff@spam_me_not.comschreef in bericht
news:Pd******************************@earthlink.co m...
> I'm having some trouble wrapping my mind around header(), I'm used
to just printing the header and leaving a blank line.

Does php ignore whitespace before a header:

<?php

// no output here
?>

just whitespace, are the line feeds ignored?

<?php
header(...)...


Be careful.

This does contain output between the two php lines which is not ignored.
---snip---
<?php $a=1; ?>

<?php header('whatever'); ?>
---snip---

The following is OK:
---snip---
<?php $a=1; ?>
<?php header('whatever'); ?>
---snip---

But that is html, not PHP code.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 28 '08 #4

P: n/a
"Jerry Stuckle" <js*******@attglobal.netschreef in bericht
news:gb**********@registered.motzarella.org...
>>Does php ignore whitespace before a header:

<?php

// no output here
?>

just whitespace, are the line feeds ignored?

<?php
header(...)...
But that is html, not PHP code.
Indeed it is.

The short answer to the question would be: "no".

Sep 28 '08 #5

P: n/a
I'm having some trouble wrapping my mind around header(), I'm used to
>just printing the header and leaving a blank line.

Does php ignore whitespace before a header:
^^^^^^ PHP does *not* ignore the whitespace here.
><?php
^^^^^^ but it ignores the whitespace here
>// no output here
?>
^^^^^^ and it does *not* ignore the whitespace here either.
>just whitespace, are the line feeds ignored?

<?php
header(...)...

Also, I take it that we can have multiple header functions. If I now
echo something or just have embedded html, I take that php inserts a
blank line and the header is finished?

Why can't I just echo the headers and not use header?

Jeff

Sep 28 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.