In fact it results in 500 Internal Server Error handled by the webserver (showing generic 'Whoops, we're sorry' message) on any correctly configured webserver. Checking for extension availability is either done during installation or before calling mysql_connect(). I was taking it for granted you checked that the function was available before calling it. However checking that the domain name resolves, host is reachable, port is open and there's something speaking MySQL protocol prior to connecting sounds like an overkill to me. In my opinion it should be discretely reported by the API to the calling code and logged only if the calling code does not handle it.Darhazer wrote:If you suppress error/warning of mysql_connect and the mysql extension is not enabled, you'll get a fatal error (call to undefined function) which results in a blank screen.
@ error suppressor
Moderator: General Moderators
Re: @ error suppressor
Re: @ error suppressor
How about in cases where you are generating a buffer using ob_start etc and you don't want to corrupt the buffer with error messages? Or in situations where you want to detect the error but output your own message and formatting?
Re: @ error suppressor
You have the ability to change error handlers, reporting levels and the display errors settings on the fly. You can do what you wish with errors as you desire.M2tM wrote:How about in cases where you are generating a buffer using ob_start etc and you don't want to corrupt the buffer with error messages? Or in situations where you want to detect the error but output your own message and formatting?
Re: @ error suppressor
Yeah, what I mean is, if you are already generating a solid error message with a callstack included it seems redundant to then also store the php generated message with less information (not always, it depends on the function being called.) Sometimes if I'm handling the error myself I will use error suppression on the function I'm calling... But of course outputting the errors to a log makes a lot of sense and that's what I have in 99% of cases.
Code: Select all
function mv_errorOutput($text, $return = false){
$location = debug_backtrace();
$locationCount = min(count($location), MV_MAX_CALLSTACK_SIZE);
$hiddenOutput = '<!--[if !IE>'."\n";
for($i = 0;$i < $locationCount;$i++){
$hiddenOutput.= ' '.$location[$i]['file'].':('.$location[$i]['line'].') => '.$location[$i]['function']."\n";
}
$hiddenOutput.= '__________________'."\n".'<![endif]-->'."\n";
$output= "\n".'<div style = "color:red;background-color:black;text-align:center;">'."\n".
$hiddenOutput.
$text.
"\n".'</div>'."\n";
if($return){
return $output;
}else{
echo $output;
}
}