Mixing php with javascrip – Heredoc

0
228

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
TEST;

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.

LEAVE A REPLY

Please enter your comment!
Please enter your name here