开发者

Where to put DTD in gzipped files?

开发者 https://www.devze.com 2023-01-19 17:26 出处:网络
I\'m adding the following: <?php ob_start( \'ob_gzhandler\' ); ?> To a file to enable gzip compression.

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?


Before all data sent to browser ^^


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号