There are heredoc ways to define strings in PHP and Python:
Php:
Copy Code code as follows:
$sql =<<<eod
SELECT *
From pages
where Pagename= ' $PN '
EOD;
Python:
Copy Code code as follows:
Print "" "
This is a example of a string in the Heredoc syntax.
This text can span multiple lines
"""
JS concatenation of a large number of strings no heredoc style operators are more cumbersome:
Splicing Way One:
Copy Code code as follows:
var str = "\
Here's line one \
and line two \
Finally, Line three! \
";
alert (str);
Splicing mode two:
Copy Code code as follows:
var __template =
' <tr> ' +
' <td> #salarySN #</td> ' +
' <td> #name #</td> ' +
' <td> #TDR_NAME #</td> ' +
' <td> #TSD_NAME #</td> ' +
' <td> #WORK_STATUS #</td> ' +
' <td> #isleader_display #</td> ' +
' <td> '
+ ' <a href= ' javascript:void ( -1) ' > Set role </a> '
+ ' </td></tr> ';
JS strings need to break the original string style, each row processing, this is a bit unbearable.
Give a solution:
Copy Code code as follows:
function Aheredoc () {/*
Hello, world!.
I am a JavaScript here document.
Use the ' HereDoc ' function to extract me.
*/}
function HereDoc (func) {
Return func.tostring (). Split (/\n/). Slice (1,-1). Join (' \ n ');
}
Console.log (HereDoc (Aheredoc));
Use Func.tostring () to get the strings that need to be processed in batches, using split (/\n/). Slice (1,-1) to remove the code from the two lines of function definition and reassemble it.