Php Fatal Error Errordocument
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn xml parsing fatal error invalid document structure more about Stack Overflow the company Business Learn more about hiring developers or
Dreamweaver Xml Parsing Fatal Error Invalid Document Structure
posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow
Xml Parsing Fatal Error Invalid Document Structure Line 1
Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Trigger 500 Internal Server Error in PHP and display
Php Catch 500 Error
Apache error page up vote 30 down vote favorite 5 How can i trigger 500 Internal Server Error or 404 Page Not Found Apache errors in PHP? For 500 Internal Server Error i have tried following code : header("HTTP/1.0 500 Internal Server Error"); But it shows me a blank page. How can i show the error in Apache's default format? Please guide.. php apache share|improve this question edited apache errordocument Sep 22 at 15:07 Álvaro González 81.2k20133201 asked Dec 31 '11 at 9:27 Vin 1,20262443 1 At first glance I thought this would be trivial to solve. But it appears it's actually not. So +1 –GordonM Dec 31 '11 at 10:00 1 Just to throw it out there for everyone: I was thinking you could just include Apache's original error document out of the shared files (/usr/share/httpd/error/HTTP_INTERNAL_SERVER_ERROR.html.var for me) and exit the PHP script. But I'm having a huge problem: how would you go about processing the .html.var file? In Apache it's set as AddHandler type-map var but I can't figure out anything that would be useful in PHP. –animuson♦ Dec 31 '11 at 10:01 add a comment| 7 Answers 7 active oldest votes up vote 8 down vote You could just copy the Apache error documents into your web root (or symlink them in) and use header() to set the error codes and with those documents as output. That's probably best unless you have a compelling reason not to. But in case that won't work for you, there are some alternatives (albeit, hacky alternatives). For 500, just put a bug in your code.
Update in 2 WeeksHTTP Status Codes and Htaccess ErrorDocuments » by Charles Torvalds 6 comments The php part of this article is based on my Advanced WordPress 404.php php error handler article from 2008. Many of the following ideas came out of the research php error types performed to enumerate every single Apache ErrorDocument, including learning how to view the defaults and many cool tricks for php catch fatal error htaccess. Contents [hide] The PHP HTTP ErrorDocument Handler Advantages and Reasons for Using {$reason} Htaccess ErrorDocument Tips Using Redirect in .htaccess to trigger Errors Powerful Mod_Rewrite Trick ErrorDocument Example for .htaccess http://stackoverflow.com/questions/8687390/trigger-500-internal-server-error-in-php-and-display-apache-error-page The PHP HTTP ErrorDocument Handler Just save this as /err.php or whatever. The best is to put it in a cgi-bin script-alias directory under your DOCUMENT_ROOT like /cgi-bin/e.php but most people don't know how. That way you can setup some advanced stuff in a /cgi-bin/.htaccess file. If you are interested in locking it down, I recommend reading Securing php.ini and php-cgi with .htaccess. Advantages http://www.askapache.com/php/php-errordocument/ and Reasons for Using Fast, HTTP Protocol Compliance, protection. If you are reading this article, you already know and just want to check out the code! 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', 207 => 'Multi-Status', 226 => 'IM Used', 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 306 => 'Reserved', 307 => 'Temporary Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Requested Range Not Satisfiable', 417 => 'Expectation F
page and ErrorDocument The SitePoint Forums have moved. You can now find them here. This forum is now closed to new posts, but you can browse existing content. You can find http://www.sitepoint.com/forums/showthread.php?436124-display_errors-blank-page-and-ErrorDocument out more information about the move and how to open a new account (if necessary) here. If you get stuck you can get support by emailing forums@sitepoint.com If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that fatal error you want to visit from the selection below. SitePoint Sponsor User Tag List Results 1 to 7 of 7 Thread: display_errors, blank page and ErrorDocument Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Nov 8, 2006,03:50 #1 kyberfabrikken View Profile View Forum Posts SitePoint Wizard Join Date Jun 2004 Location Copenhagen, Denmark Posts 6,157 Mentioned 0 Post(s) Tagged xml parsing fatal 0 Thread(s) display_errors, blank page and ErrorDocument I have php running with the directive display_errors = Off on a production site. If an error occurs, this will result in a blank screen, which isn't very helpful to my users. I have therefore tried to configure apache to display a custom errorpage on the most common errors, but I'm having trouble getting it to work. In this article it's suggested that if I send an errorcode with PHP's header function, apache should serve the custom errorpage, but this doesn't seem to work for me. If I generate an http-error from apache itself - eg. selecting a page, that doesn't exist - the custom errorpage is displayed though. Does anybody know what I'm missing here? Introducing pearhub | Konstrukt 2.3.1 | twitter.com/troelskn Nov 8, 2006,03:57 #2 Jeraych View Profile View Forum Posts SitePoint Zealot Join Date May 2004 Location houston Posts 176 Mentioned 0 Post(s) Tagged 0 Thread(s) What kind of errors are you looking to catch? Why not make your own error handling function? http://us3.php.net/manual/en/functio...or-handler.php Alot of functions also return bool, so you can check to see if they actually 'worked', and use an if statement to check and return what you want.. To have a function