Well, I think that as such there is no way to find out the standard 404 error page, so I did this trick:
In .htaccess I wrote the following lines that intercept the main errors:
ErrorDocument 400 /errors.php?code=400 ErrorDocument 403 /errors.php?code=403 ErrorDocument 404 /errors.php?code=404 ErrorDocument 405 /errors.php?code=405 ErrorDocument 408 /errors.php?code=408 ErrorDocument 500 /errors.php?code=500 ErrorDocument 502 /errors.php?code=502 ErrorDocument 504 /errors.php?code=504
It's all clear. The errors.php script gets the error code via GET and displays the text we need.
And here is the function that creates the error. Anyone that I would need
function throw_error($code = 404) { //проверяем, отправлены ли заголовки if (!headers_sent($filename, $linenum)) { $code = int($code); //коды основных ошибок $codes = array( 400 => "400 Bad Request", 403 => "403 Forbidden", 404 => "404 Not Found", 405 => "405 Method Not Allowed", 408 => "408 Request Timeout", 500 => "500 Internal Server Error", 502 => "502 Bad Gateway", 504 => "504 Gateway Timeout", ); //убеждаемся, что такая ошибка есть в массиве $status = "404 Not Found"; if (isset($codes[$code])) { $status = $codes[$code]; } else { $code = 404; } //отправляем заголовки $sapi_name = php_sapi_name(); if ($sapi_name == 'cgi' || $sapi_name == 'cgi-fcgi') { header('Status: '.$status); } else { header($_SERVER['SERVER_PROTOCOL'] . ' '.$status); } /* Костыль, знаю, зато работает. Вывод страницы с ошибкой Не include, потому что на страницах используются константы, которые имеют широкую область видимости. */ echo file_get_contents('http://'.$_SERVER['HTTP_HOST'].'/errors.php?code='.$code); exit(); } else { //если заголовки уже отправлены, говорим об этом echo "Sorry... Headers already sent on line $linenum"; exit(); } }