Your PHP can go anywhere since the browser never sees it but the doctype must be the first thing the browser sees followed by the html tag.
OK
<?php
// blahity blah
?>
<!DOCTYPE html blahity blah>
<html>
Not OK
<?php
echo 'Hello'; // this puts text before the doctype
?>
<!DOCTYPE html blahity blah blah>
<html>
ShawnCplus
Code Monkey
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268