As a suggestion, if you’re going to generate your HTML on the fly, it may not be a bad idea to create PHP objects to wrap your HTML Generation. I’ve done this in my code base, and it removes issues like that completely (since I only need to be sure that I’ve created syntactically correct HTML once, instead of on every line).
So, for instance, this is an example Form created during a test page that I’ve written to test Session Access Methods:
$form = new HTMLForm();
$form->setCustomStyle(array("action", "method"), array("?", "post"));
$form->addElement("This is a test textbox: ");
$form->addElement(new FormInput(array("type", "name", "value"), array("text", "test", "cars")));
$form->addElement("<br />\
");
$form->addElement(new FormInput(array("type", "value"), array("submit", "Submit")));
$form->display();
And the output looks like this:
<form action = "?" method = "post">
This is a test textbox: <input type = "text" name = "test" value = "cars">
<br />
<input type = "submit" value = "Submit">
</form>
I know how I did it in a way which works for me, though I can’t promise that it will be the best choice for you. There will likely be purists (especially MVC purists) who criticize it for a lack of separation, and they’ve got valid points, but part of the beauty of PHP is its flexibility with things like this.
Hope that gives you an idea, if you have any questions, I’d be happy to help. I know it’s definitely saved me a TON of debugging time. 