Download the latest
XYplorer BETA version (v7.90.0051, 13-jan-2009).
Choose one: (1)
Install Package, (2)
No-Install Package (each about 1 MB).
Code: Select all
v7.90.0051 - 2009-01-13 21:00
+ Scripting: Added the so-called Heredoc syntax: <<<ID...
Heredoc is a way to define multi-line strings "as is" without the
need to escape quotes etc.
Rules
~~~~~
The rules follow the PHP rules for Heredoc:
- After the <<< operator, an identifier (your free choice) is
provided, then a new line. The string itself follows, and then
the same identifier again to close the quotation. The closing
identifier must begin in the *first* column of the line (no
indent!). The line with the closing identifier must contain no
other characters, except possibly a semicolon (;) directly after
the identifier.
- Heredocs overwrite comments, and comments overwrite heredocs,
depending on who comes first.
Within the Heredoc section:
- Line feeds, empty lines, and all kinds of comments survive.
- Lines are not trimmed (leading and trailing spaces are preserved).
- Quoting is handled automatically (no need to add outer quotes or
to double inner quotes).
- Variables are resolved.
Example 1
~~~~~~~~~
Script:
---------------------------------------------------------------
$name = "Bond";
text <<<FOO
My name is $name, "James $name". // line end comment: $name
Follow /* note: there's one space after me, */ me,
FOO
."please!";
---------------------------------------------------------------
Output:
---------------------------------------------------------------
My name is Bond, "James Bond". // line end comment: Bond
Follow /* note: there's one space after me, */ me, please!
---------------------------------------------------------------
Example 2
~~~~~~~~~
Note, how you can use two (or more) Heredocs in one statement.
Script:
---------------------------------------------------------------
text <<<FOO
"Bond";
FOO
.<<<FOO
"James Bond";
FOO;
---------------------------------------------------------------
Output:
---------------------------------------------------------------
"Bond";"James Bond";
---------------------------------------------------------------