That’s the problem; and also the snippet author not following recommended coding practices.
Line 2:
$output = "<script type="text/javascript"> ...
Either you have the quotes in the output string escaped with a backslash ( \"text/javascript\" ) or you use single quotes, either for the outer level or the inner level of quotes:
$output = "<script type='text/javascript'> ...
Looking at the code in this snippet, the author used every variation possible!