tags:

views:

21

answers:

2

I'm adding the following:

<?php ob_start( 'ob_gzhandler' ); ?>

To a file to enable gzip compression.

Should it go before the DTD, or between it and the <html> tag?

+2  A: 

Before all data sent to browser ^^

MatTheCat
+1  A: 

It has to go before the DTD and any other output. The < of <?php must be the absolute first byte of the file otherwise there is literal output before it (even if that's only whitespace, or a UTF-8 fake-BOM emitted by a misguided Windows text editor).

Any <!DOCTYPE> declaration in a .php file is just pure output text, something that applies to the returned HTML page and not the PHP file itself (as PHP is neither HTML nor XML).

bobince