note 84291 modified in function.header by danbrown

From: Date: Sun, 07 Dec 2008 17:59:03 +0000
Subject: note 84291 modified in function.header by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-147795@lists.php.net to get a copy of this message
if you use php to create custom error pages (such as header('HTTP/1.1 500 Internal Server Error');) Internet Explorer ignores you custom page unless it is at least 512 (or sometimes 1024 bytes) IE ignores custom error pages that are less than 512 (or from what i've read 1024) bytes. just place this before any output on your custom error page--- and be sure that your custom error page includes proper html tags (it must have a </body> for this specific example to work) <?php // set your custom error header --- example --- header('HTTP/1.1 503 Service Unavailable'); function padding($html){ return ($padding=1024-ob_get_length()) > 0 ? str_replace('</body>','<!--'. ($padding>8?str_repeat(' ',$padding-8) :null ).'-->'."\n".'</body>',$html) : $html; } ob_start('padding'); ?> and then place this somewhere within the html error page output <!-- ---- --> that will auto-adjust to pad the file to 1024 bytes to override the default Internet Explorer error pages. --was-- heres a fix for my last post- IE ignores custom error pages that are less than 512 (or from what i've read 1024) bytes. the past post broke with the release of firefox 3.0 which treats any -- inside of a html comment as a end of comment and not just --> like in the past here the fix just place this before any output on your custom error page--- and be sure that your custom error page includes proper html tags (it must have a </body> for this specific example to work) <?php // set your custom error header --- example --- header('HTTP/1.1 503 Service Unavailable'); function padding($html){ return ($padding=1024-ob_get_length()) > 0 ? str_replace('</body>','<!--'. ($padding>8?str_repeat(' ',$padding-8) :null ).'-->'."\n".'</body>',$html) : $html; } ob_start('padding'); ?> http://php.net/manual/en/function.header.php

« previous php.notes (#147795) next »