Results 1 to 2 of 2

Thread: Does newline (\n) only work with double quotes?

  1. #1
    Join Date
    Apr 2008
    Location
    San Diego, CA
    Posts
    352
    Thanks
    57
    Thanked 6 Times in 6 Posts

    Default Does newline (\n) only work with double quotes?

    EDIT: Yep, only works with double quotes. I didn't realize there were so many differences in single and double quotes in PHP - that is definitely going to come in handy in the future!

    If you want to keep using single quotes, just do it with concatenation: $var = '$someLiteralString'."\n";


    Hi all,

    This is working for me:

    Code:
    echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"http://yui.yahooapis.com/2.7.0/build/container/assets/skins/sam/container.css\" />\n";
    But this one prints the "\n" as text:

    Code:
    echo '<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/container/assets/skins/sam/container.css" />\n';
    Do you HAVE to use double quotes with newlines? Could this be something specific to the PHP setup? I'm still new to PHP.

    Thanks a bunch for any help.
    Last edited by jlizarraga; 06-26-2009 at 07:01 PM. Reason: typo
    My site: FreshCut :)

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Simplest thing I've figure is double quotes means render, single means leave it as is.

Bookmarks

Posting Permissions

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