Yes it is a PHP error, and an infuriating one to boot.
The problem is this:
When you have a blank space, or line between PHP code blocks, that blank space is output to the header of the page, the same as if you had a character there.
The PHP header() function or the session_start() function must occur before anything is output to the page, since it modifies the header prtion of the page. If there is any output on the page, the header() or session_start() functions cannot modify the header, so the headers already sent error occurs.