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?
| SitePoint Sponsor |




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?
What does it do?




Using it you can put ANY text or HTML into variable without converting " to \" etc.
For example:
But in JS I should use for this:PHP Code:$variable = <<<TEXT
any kind of text or "html" or something else
you can use a lot of rows
...
TEXT;
HTML Code:$variable = "any kind of text or \"html\" or something else" + "you can use a lot of rows" + "...";
Unfortunately, you have to manually escape quotes in JavaScript.









In javascript you can use backslash to continue string literal on the next line
Code:a = "row1 \ row2 \ row3"
Bookmarks