php isn't really my thing, but it seems like you need to clear the response stream before writing out your content. Perhaps something else is writing html out to the stream, before reaching this function? Like a template or master page or something of that nature?
The HTML content looks like a typical header/nav bar. if there something else that's automatically including that content that you need to disable for this route?