I have a html template as a php string. To prevent output, all blank characters and line breaks before the html opening or doctype definition should be removed. What is the simplest and fastest way to do this with PHP?
+2
A:
If I interpret your question as simply, "How do I remove whitespace from the beginning of a string", the answer is simply:
$str = trim($str);
Ben James
2010-05-06 13:47:27
Hmm... Thanks. Will need to check why it's not working in my application...
Workoholic
2010-05-06 14:02:49
Also make sure to set your mime type right:`header('Content-type: application/xhtml+xml, encoding=utf-8');`this will help to force some browsers into strict mode.
Rodin
2010-05-06 15:42:52
A:
If you are using some kind of MVC framework, you would find the output method in the view and trim the string.
MANCHUCK
2010-05-06 14:09:58