views:

76

answers:

2

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
Hmm... Thanks. Will need to check why it's not working in my application...
Workoholic
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
A: 

If you are using some kind of MVC framework, you would find the output method in the view and trim the string.

MANCHUCK