This essentially boils down to two kinds of errors. Syntax/parser errors, and runtime/logic errors.
For the syntax/parser errors, you're probably out of luck. In those cases the script itself can't execute, so by definition the script can't respond to the errors. The best defense against this is testing (preferably automated). One thing you can do is set your error logging to be a database instead of a file. But the script itself still can't respond to the error.
For runtime/logic errors, this is where exception handling comes into practice. There's a lot that can go into it, but the overall structure is simple enough:
try {
// perform some operation
} catch (Exception $e) {
// an error occurred, the details of which are in $e
// meaningfully respond to it
}