PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
That error usually indicates that something has been output first. You say wherever you put it but I'm guessing that there is an include() or something else above?
If your entire page just has the php tag and then that code all should be well.
If you are including any files then it will be whitespace in them - I suggest you have a look at output buffering using ob_start() as the very first line in the file before any includes and then ob_end_flush just before your header output.