...
The code does use some techniques which are worth understanding:
We use an array of string strings and concatenate them at the end for performance.
We escape characters like & < and > to translate into HTML entities so that data can be not mis-interpreted and HTML markup.
We use a magic token '
_FuNkYDolARAM
' to handle the convention of allows a double $$ escape sequence to represent a $ character.
...