Reply to comment

PHP's <<< returns a value

A not well documented feature of heredocs or <<< in PHP is that it returns the string, making it possible to use with variables as well as with echo or print statements/constructs/functions:


$variable = 'Edge'
$toprint = <<< END
Something with an $variable

END;

The output wil be

Something with an Edge

See http://en.wikipedia.org/wiki/Here_document#PHP for more information on heredocs

Reply

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <h3> <h4>
  • Lines and paragraphs break automatically.

More information about formatting options