WordPress.org

Ready to get started?Download WordPress

Forums

Will whitespace (tabs, spaces, etc) make bricks? (4 posts)

  1. swimswimswim
    Member
    Posted 7 years ago #

    I just read in another post that a tab at the beginning of a file messed up the system.

    Say what?

    Html ignores any whitespace greater than one space (unless it is coded as a space:  ). I assumed the same with php. Is that incorrect?

    Will whitespace (i.e. spaces and tabs) mess up php?

  2. moshu
    Member
    Posted 7 years ago #

    If it is before the first
    <?php...
    YES, it will.

  3. swimswimswim
    Member
    Posted 7 years ago #

    Wow, that's bananas.
    Thanks.

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    Will whitespace (i.e. spaces and tabs) mess up php?

    Not directly, no. But it can.

    PHP gives you the ability to modify the actual HTTP headers directly. WordPress uses this ability. However, if there is actual output, including whitespace, before the attempt to modify the headers, then you get an error. This is because the headers must come first in the resulting output.

    HTML does not give you the ability to modify headers. PHP is generating HTML code as output, but it has those headers to deal with too. So yes, in certain cases, badly placed whitespace can break your page.

    Now, it won't do it in (most of) the Template files, which is the only thing an inexperienced user should ever be editing. But it can do it in plugins or the functions.php template file.

Topic Closed

This topic has been closed to new replies.

About this Topic