Windows PHP 5.2.6 - Problems with Escape Characters

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • scopnd@gmail.com

    Windows PHP 5.2.6 - Problems with Escape Characters

    Hi,

    I'm new to PHP and I am working through tutorials. I am running PHP
    5.2.6, on windows xp. I am having problem with escape characters, they
    do not seem to work. The below code example should display on multiple
    lines, it just displays on 1 line no '\n' line breaks, it's ignored.
    Is there something I need to set in the php.ini file? The php seems to
    be installed fine as I can call functions etc.

    <?php
    $text = "A very long woooooooooooord .";
    $newtext = wordwrap($text, 8, "\n", true);

    echo "$newtext\n ";
    ?>


    Thanks

    Ned
  • Guillaume

    #2
    Re: Windows PHP 5.2.6 - Problems with Escape Characters

    scopnd@gmail.co m a écrit :
    The below code example should display on multiple
    lines, it just displays on 1 line no '\n' line breaks, it's ignored.
    Is there something I need to set in the php.ini file? The php seems to
    be installed fine as I can call functions etc.
    >
    <?php
    $text = "A very long woooooooooooord .";
    $newtext = wordwrap($text, 8, "\n", true);
    >
    echo "$newtext\n ";
    ?>
    Are you trying it through your browser ? Cause then, it displays as
    expected in the source code only, while your browser doesn't handle
    newlines and display all lines concatenated.
    You can easily change it by echoing nl2br("{$newtex t}\n"); (I prefer
    using curly brackets into double-quoted strings)

    Regards,
    --
    Guillaume

    Comment

    • Michael Austin

      #3
      Re: Windows PHP 5.2.6 - Problems with Escape Characters

      scopnd@gmail.co m wrote:
      Hi,
      >
      I'm new to PHP and I am working through tutorials. I am running PHP
      5.2.6, on windows xp. I am having problem with escape characters, they
      do not seem to work. The below code example should display on multiple
      lines, it just displays on 1 line no '\n' line breaks, it's ignored.
      Is there something I need to set in the php.ini file? The php seems to
      be installed fine as I can call functions etc.
      >
      <?php
      $text = "A very long woooooooooooord .";
      $newtext = wordwrap($text, 8, "\n", true);
      >
      echo "$newtext\n ";
      ?>
      >
      >
      Thanks
      >
      Ned

      try

      echo "<pre>$newtext\ n</pre>";

      browsers may not treat \n as <brunless it is within the <pretags.

      Comment

      • scopnd@gmail.com

        #4
        Re: Windows PHP 5.2.6 - Problems with Escape Characters

        Thank you all very much.

        Yep I was testing through the browser, your suggetions worked.

        Thanks again.

        Comment

        Working...