Force Error 500 Php
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
Simulate 500 Error
this site About Us Learn more about Stack Overflow the company Business how to create 500 internal server error Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask
How To Trigger 500 Error
Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up simulate 500 error apache How to send 500 Internal Server Error error from a PHP script up vote 52 down vote favorite 18 I need to send "500 Internal Server Error" from an PHP script under certain conditions. The script is supposed to be called by a third party app. The script contains a couple of die("this happend") statements for which I need to send the 500 php return 404 error Internal Server Error response code instead of the usual 200 OK. The third party script will re-send the request under certain conditions which include not receiving the 200 OK response code. Second part of the question: I need to setup my script like this: I need to send 200 header only after the last line has been executed. Edit A side question: can I send strange 500 headers such as these: HTTP/1.1 500 No Record Found HTTP/1.1 500 Script Generated Error (E_RECORD_NOT_FOUND) HTTP/1.1 500 Conditions Failed on Line 23 Will such errors get logged by the webserver? php header http-headers share|improve this question edited Nov 19 '15 at 1:33 pnuts 33.8k63769 asked Nov 12 '10 at 6:40 Salman A 122k44259337 is not doable when u sent header and remove header later –ajreal Nov 12 '
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
Php Http_response_code
this site About Us Learn more about Stack Overflow the company Business Learn php return error message more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question
Php Return 500
x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How http://stackoverflow.com/questions/4162223/how-to-send-500-internal-server-error-error-from-a-php-script to return an HTTP 500 code on any error, no matter what up vote 32 down vote favorite 2 I'm writing an authentication script in PHP, to be called as an API, that needs to return 200 only in the case that it approves the request, and 403 (Forbidden) or 500 otherwise. The problem I'm running into is that php returns 200 in http://stackoverflow.com/questions/3052715/how-to-return-an-http-500-code-on-any-error-no-matter-what the case of error conditions, outputting the error as html instead. How can I make absolutely sure that php will return an HTTP 500 code unless I explicitly return the HTTP 200 or HTTP 403 myself? In other words, I want to turn any and all warning or error conditions into 500s, no exceptions, so that the default case is rejecting the authentication request, and the exception is approving it with a 200 code. I've fiddled with set_error_handler() and error_reporting(), but so far no luck. For example, if the code outputs something before I send the HTTP response code, PHP naturally reports that you can't modify header information after outputting anything. However, this is reported by PHP as a 200 response code with html explaining the problem. I need even this kind of thing to be turned into a 500 code. Is this possible in PHP? Or do I need to do this at a higher level like using mod_rewrite somehow? If that's the case, any idea how I'd set that up? php http response share|improve this question edited Jun 22 '12 at 14:08 BoltClock♦ 384k949351047 asked Jun 1
Start 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 http://serverfault.com/questions/30487/force-apache-to-display-php-errors-instead-of-500 Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Server Fault Questions Tags Users Badges Unanswered Ask Question _ Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and 500 error rise to the top Force Apache to display PHP errors instead of 500 up vote 2 down vote favorite I have a development server with Apache 2.2.8 /PHP 5.2.4 on Ubuntu Server 8.04. Sometimes my php code returns an Internal server 500 error instead of outputting the errors to the page. The Apache error.log contains no entries regarding the 500 error and the access.log only contains the one simulate 500 error line referencing that the 500 error occurred. In php.ini error_reporting = E_ALL and display_errors = On. How do I get Apache or PHP to display the error on the page instead of a generic 500 error. linux apache-2.2 ubuntu php share|improve this question asked Jun 23 '09 at 18:11 James 26125 add a comment| 2 Answers 2 active oldest votes up vote 3 down vote Your google-fu fails you, small grasshopper. http://ca3.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting share|improve this answer answered Jun 23 '09 at 18:45 Ernie 3,23522133 @Ernie: Who need Google, when I've got you. Thanks! –blunders Oct 15 '10 at 3:57 Note to anyone else new to php ini - error reporting must be enabled after the line engine = On, otherwise it will not work. –Nico Burns Nov 3 '10 at 18:10 add a comment| up vote 1 down vote Found the issue. Developer was using someone else's library and failed to notice that the library had custom error handling code built in. Changed one line of code and all is well. share|improve this answer answered Jun 23 '09 at 19:28 James 26125 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using G