Results 1 to 6 of 6

Thread: Why won't that line feed???

  1. #1
    Join Date
    Jan 2003
    Location
    DE
    Posts
    27

    Red face Why won't that line feed???

    Helo, ACK...

    I have a peculiar problem concerning the linefeed string in PHP 4.3.0.
    Every time I use \n it just won't work. In all the other scripts like PHPmyAdmin they work. Something is wrong with my notation, I guess (what else should it be?...)

    Example:

    ' echo "This is a linefeed test.\nThis should be the next line, but it isn't!"; '

    What am I doing wrong???

  2. #2
    Join Date
    Mar 2003
    Posts
    3
    First of all, sorry for my english!

    What are you trying to achieve with this linefeed.

    Because you spoke about PHPMyAdmin, I think you want a linefeed on your webpage. \n only makes a linefeed in the html source code but not on the page itself. If you want a linefeed on your page you have to write something like this:

    echo "This is a linefeed test.<br>\nThis is the next line!";

    --> this will create HTML Source like this
    This is a linefeed test.<br>
    This is the next line!

    --> and output on the page like this
    This is a linefeed test.
    This is the next line!

    another example
    echo "This is a linefeed test.<br>This is the next line!";

    -->HTML Source
    This is a linefeed test.<br>This is the next line!

    -->BROWSER OUTPUT
    This is a linefeed test.
    This is the next line!

    last example
    echo "This is a linefeed test.\n This is NOT the next line!";

    -->HTML Source
    This is a linefeed test.
    This is NOT the next line!

    -->BROWSER OUTPUT
    This is a linefeed test. This is NOT the next line!

    I hope I've understand your question in the right way.

    Greetings,
    Stefan

  3. #3
    Join Date
    Jan 2003
    Location
    DE
    Posts
    27

    Talking Jup verstanden...

    Das Problem war der HTML output.
    Ich habe zwischenzeitlich auch gemerkt, dass ich nur mit dem <br>-TAG den Zeilenvorschub erzwingen kann... Frage mich nur wozu dann der C string \n gut ist!?

  4. #4
    Join Date
    Dec 2002
    Location
    Cape Town, South Africa
    Posts
    75
    Couple of possibilities:

    1) You're displaying on a browser, so you need to use <br> instead of \n.

    2) You're not running on a Unix system. Newlines on the various Operating Systems are:
    Macintosh: \r
    Unix : \n
    Windows : \r\n

  5. #5
    Join Date
    Mar 2003
    Posts
    3

    Re: Jup verstanden...

    Originally posted by MuSQLe
    Das Problem war der HTML output.
    Ich habe zwischenzeitlich auch gemerkt, dass ich nur mit dem <br>-TAG den Zeilenvorschub erzwingen kann... Frage mich nur wozu dann der C string \n gut ist!?
    Der erzeugt Dir einen Zeilenumbruch innerhalb des HTML "Quellcodes", was aber nicht mit einem Umbruch (<br>) auf der Seite selbst (beim ansehen im Browser) zu verwechseln ist. (siehe nochmal obige Beispiele)

  6. #6
    Join Date
    Jan 2003
    Location
    DE
    Posts
    27

    Thumbs up Good to know...

    OK, I can understand that.
    I never payed attention to the linebreaks and the linefeed in the source-code. Now I know, thanks...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •