SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru
    Join Date
    Mar 2004
    Posts
    639
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Does JavaScript have <<<TEXT analog?

    Hello guys,

    I'm using PHP's <<<TEXT TEXT; a lot and I'd like to use something similar with JS. Is it possible? Does JS have <<<TEXT analog?

  2. #2
    SitePoint Evangelist bals28mjk's Avatar
    Join Date
    Aug 2007
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What does it do?

  3. #3
    SitePoint Guru
    Join Date
    Mar 2004
    Posts
    639
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bals28mjk View Post
    What does it do?
    Using it you can put ANY text or HTML into variable without converting " to \" etc.

    For example:

    PHP Code:
    $variable = <<<TEXT
    any kind of text or "html" or something else
    you can use a lot of rows
    ...
    TEXT; 
    But in JS I should use for this:

    HTML Code:
    $variable = "any kind of text or \"html\" or something else" +
    "you can use a lot of rows" +
    "...";

  4. #4
    SitePoint Evangelist bals28mjk's Avatar
    Join Date
    Aug 2007
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately, you have to manually escape quotes in JavaScript.

  5. #5
    SitePoint Guru
    Join Date
    Mar 2004
    Posts
    639
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bals28mjk View Post
    Unfortunately, you have to manually escape quotes in JavaScript.
    I see.

    Thanks for help.

  6. #6
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In javascript you can use backslash to continue string literal on the next line

    Code:
    	a = 
    		"row1 \
    		row2  \
    		row3"


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
  •