The PHP code should not display to the browser. Your query as to why the XHTML validator is failing your code is not really a PHP question but more an HTML question.
I suggest you post the entire HTML code (copy/pasted from the browser View Source). Some people here may be able to help you work out why the XHTML validator doesn't like your code, but a better forum would be the HTML and CSS one here: http://www.daniweb.com/forums/forum143.html