header questions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff

    header questions

    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
  • Jerry Stuckle

    #2
    Re: header questions

    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.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • mijn naam

      #3
      Re: header questions

      "Jeff" <jeff@spam_me_n ot.comschreef in bericht
      news:Pd-dnVfo9c2pFELVnZ 2dnUVZ_hadnZ2d@ earthlink.com.. .
      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('whateve r'); ?>
      ---snip---

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

      Comment

      • Jerry Stuckle

        #4
        Re: header questions

        mijn naam wrote:
        "Jeff" <jeff@spam_me_n ot.comschreef in bericht
        news:Pd-dnVfo9c2pFELVnZ 2dnUVZ_hadnZ2d@ earthlink.com.. .
        > 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('whateve r'); ?>
        ---snip---
        >
        The following is OK:
        ---snip---
        <?php $a=1; ?>
        <?php header('whateve r'); ?>
        ---snip---
        >
        >
        But that is html, not PHP code.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • mijn naam

          #5
          Re: header questions

          "Jerry Stuckle" <jstucklex@attg lobal.netschree f in bericht
          news:gboa8d$24n $1@registered.m otzarella.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".

          Comment

          • Gordon Burditt

            #6
            Re: header questions

            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

            Comment

            Working...