NYCPHP Meetup

NYPHP.org

[nycphp-talk] Can I set the response code if a PHP Fatal error occurs?

Michael Sims jellicle at gmail.com
Tue Feb 17 12:54:53 EST 2009


On Tuesday 17 February 2009, lorband at optonline.net wrote:

> Your reply is perfectly logical but I am trying not to redesign alot of
> code. The PHP code is currently designed to return  a string or nothing
> depending on the action taken. If a fatal error occurs, nothing is
> returned which unfortunately is also a valid response.

Exactly.  You've identified the problem precisely: your Javascript currently 
can't distinguish between success and failure.  I described how to do that: 
on success, send something specific (I used the word "good"), and have the 
Javascript look for it.  You don't have to echo it to the screen or 
anything, just look for it and be happy if it comes.  In ANY case when you 
don't get that specific response, some error has occurred and the Javascript 
should therefore be unhappy and tell the user that something is not right.

There's no other way to do it.  You can't have nothing be a valid response 
because as you've seen, it's possible to get nothing as an error response 
too.

Michael Sims

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20090217/b01cddc2/attachment.html>


More information about the talk mailing list