0

I forgot how to write the one command that looked something like this

<<TOC


bla bla

bal bal


TOC;

how was it written again?

hakre
  • 193,403
  • 52
  • 435
  • 836

4 Answers4

8

These are called heredocs.

Sean Bright
  • 118,630
  • 17
  • 138
  • 146
2

It works like this:

$foo = <<<TOKEN
multi
line
string
TOKEN;

TOKEN can be anything you want as long as you being and end the heredoc with the same exact thing.

Andrew Hare
  • 344,730
  • 71
  • 640
  • 635
2

Yes that is corect syntax for using a heredoc, however make sure that TOC; line is not indented or it will not work. FYI you can call it anything you want such as HTML not just TOC.

teh_noob
  • 1,106
  • 3
  • 12
  • 25
2

Good Examples:

$foo = <<<TOKEN⁋
multi⁋
line⁋
string⁋
TOKEN;⁋

However, these don't work

$foo = <<<TOKEN‧anything here⁋
multi⁋
line⁋
string⁋
TOKEN;‧anything here⁋
$foo = <<<TOKEN
multi⁋
line⁋
string⁋
‧TOKEN;
$foo = <<<TOKEN
multi⁋
line⁋
string⁋
→TOKEN;

The closing token must be on its own line, hard up against the left margin, followed directly with its following semi colon, followed directly with a carriage return.

Kent Fredric
  • 56,416
  • 14
  • 107
  • 150