Mixing php with javascrip – Heredoc

My main issue with javascript is the fact it is full of ‘ and ” which can be a real pain when coding. I’ve started using a method called heredoc to set a start and end point, example below.

// Heredoc string //
$sstring = <<<TEST
Hello World

The word TEST could be anything and it wont finish inputing the string until it comes across it again. This is a really simple way to add a portion of javascript to php code.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *