CR/LFs eaten by PHP !?

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

    CR/LFs eaten by PHP !?

    Env.: PHP 4.4.0 / IIS 5.1 / XP Pro

    Hi All,

    I'm writing a PHP page which contains plain text.
    Oddly enough, it there is a CRLF right after a php tag, this CRLF is eaten
    and doesn't appear on the client side.

    e.g.:
    <?php header('Content-type: text/plain') ?>
    a:<?php whatever(); ?>
    b:123
    c:456

    This script appear at the client as:
    a:whateverb:123
    c:456

    instead of :

    a:whatever
    b:123
    c:456

    I noticed that adding a 2nd CRLF is a workaround since one CRLF then appears
    at the client side. Adding any character (such as a space) between the php
    tag and the crlf also preserves the CRLF.
    However, I'd like to understand what happens. Is there a way to tell PHP to
    preserve my CRLFs ?

    TIA,

    Serge
    serge at wautier dot net



  • Oli Filth

    #2
    Re: CR/LFs eaten by PHP !?

    Serge Wautier wrote:[color=blue]
    > Env.: PHP 4.4.0 / IIS 5.1 / XP Pro
    >
    > Hi All,
    >
    > I'm writing a PHP page which contains plain text.
    > Oddly enough, it there is a CRLF right after a php tag, this CRLF is eaten
    > and doesn't appear on the client side.
    >
    > e.g.:
    > <?php header('Content-type: text/plain') ?>
    > a:<?php whatever(); ?>
    > b:123
    > c:456
    >
    > This script appear at the client as:
    > a:whateverb:123
    > c:456
    >
    > instead of :
    >
    > a:whatever
    > b:123
    > c:456
    >
    > I noticed that adding a 2nd CRLF is a workaround since one CRLF then appears
    > at the client side. Adding any character (such as a space) between the php
    > tag and the crlf also preserves the CRLF.
    > However, I'd like to understand what happens. Is there a way to tell PHP to
    > preserve my CRLFs ?
    >[/color]



    --
    Oli

    Comment

    • Serge Wautier

      #3
      Re: CR/LFs eaten by PHP !?

      Great ! thanks !

      "Oli Filth" <catch@olifilth .co.uk> wrote in message
      news:1129644274 .038037.182890@ g43g2000cwa.goo glegroups.com.. .[color=blue]
      >
      >
      > http://www.php.net/manual/en/faq.usi...using.newlines
      >
      > --
      > Oli
      >[/color]


      Comment

      Working...