I'm trying to use PHP to generate a JavaScript switch block by taking input from TemplateList.txt. It works fine when I only have one line in TemplateList.txt, but when I have two or more I get an error in the console saying I have a
SyntaxError: unterminated string literal
on the line of the php opening tag, I can't see any unclosed strings.
<?php
$listHandle = fopen('templates/TemplateList.txt', 'r');
while (!feof($listHandle)) {
$thisTemplate = fgets($listHandle);
echo "case \"" . $thisTemplate . "\": " . $thisTemplate . "(); break; ";
}
fclose($listHandle);
?>
My TemplateList.txt file looks like this:
heart_by_john
dog_by_sue
What am I doing wrong?