Posted about 1 year ago, by Specific

Strings can get really complicated the bigger they get in PHP.  In order to allow people to easily write large amounts of text from within PHP, but without the need to constantly escape charactors, heredoc was developed.  Heredoc might be a little tricky to understand at first, however, it will help in the end.  It allows you to define your own string limiter so that you can make it something other than a double or single quote.

Here is an example using Heredoc:

You start by using <<< followed by  your specified delimiter to enter heredoc mode.  To end heredoc, you must use the delimiter you declared on a single line with no spaces around it, followed by the closing semi-colon (;).

Author Info Comment