Your problem is most likely in a previous line where you are appending your $html var. Why are you doing this anyway? Oh well, your business. But an unclean HTML tag may be causing you problems since this looks OK. Does anyone else see a problem? This looks like a contextual HTML interpreter error due to bad HTML tags .