#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    50
    Rep Power
    15
    Does anyone know why escape sequence chars. dont work?
    ie. n t dont seem to work
    eg.1
    <?php
    echo ("HelloWorldn"); // the n doesnt work
    ?>

    when i try:
    eg2
    <?php
    echo "HelloWorld<br>"; // the newline works with the html <br> tag
    ?>

    also:
    eg3
    <?php
    echo ("HelloWorld<br>n"); // this works too
    ?>

    I am finding it very funny, is it a bug in the PHP or what?
    Also why in eg2, is it that an html tag is working in PHP statement when the n or t etc. should be working.
    And what bout eg3, that seems even more odd.?

    Does anyone know what the prob. could be.?
    My version of PHP is PHP4.0.1pl2

    cheers,
    duke.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Roseburg, OR, USA
    Posts
    23
    Rep Power
    0
    /n will create a new line in your html source only, not in the output

    <br> will create a new line in the html output

  4. #3
  5. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    DukeNM,
    Actually your newline does not make any impact on your browser.the second and third example you have given a BREAK that is why it is pring in next line..


    see this example..

    test.php3

    <?
    $values="Hello from n Shiju";
    echo $values;
    ?>


    if you run this script..you will see "Hello from Shiju" on the scree with out any break.

    but if you right click and see the source code you will see something like..

    Hello from
    Shiju

    ..that means ..the above lines browser can't put it in two lines becoz you haven't put a <br> thier..


    you can tackle this proble using nl2br() function in php..

    try the above example and see how it works..

    <?
    $values="Hello from n Shiju";
    echo nl2br($values);
    ?>




    ------------------
    SR -
    webshiju.com
    www.jobxyz.com-IT Career Portal
    ezipindia.com--WebStudio


    "The fear of the LORD is the beginning of knowledge..."

Similar Threads

  1. illegal escape characters
    By raynihnio in forum Java Help
    Replies: 1
    Last Post: February 12th, 2004, 09:44 AM
  2. Escape characters?
    By rampguy in forum PHP Development
    Replies: 1
    Last Post: January 18th, 2004, 11:13 PM
  3. escape characters like "
    By kinetic in forum ASP Programming
    Replies: 6
    Last Post: December 1st, 2003, 12:43 PM
  4. css transparency and layer sequence problems
    By sileebailey in forum CSS Help
    Replies: 3
    Last Post: November 14th, 2003, 02:35 AM
  5. Why does mySQL have to escape characters? (backslashes)
    By pezagent in forum PHP Development
    Replies: 1
    Last Post: October 20th, 2003, 11:08 AM

IMN logo majestic logo threadwatch logo seochat tools logo