Sure; PHP doesn't care what it outputs. HTML, XML, CSS, JS, PDF .... it's all the same as far as PHP is concerned.
It makes a difference to the client receiving the file of course, becuase it needs to know what to do with it; but that's what the Content-Type: [man]header[/man] is for.