Switch to full style
Dynamic open source server-side web development
Post a reply

Understanding PHP error messages

Sat Dec 04, 2010 4:49 pm

There are seven main categories of error, presented here in descending order of importance: :Dash: :Dash: :Dash:
    Fatal error: Any HTML output preceding the error will be displayed, but once the error is encountered—as the name suggests—everything else is killed stone dead. A fatal error is normally caused by referring to a nonexistent file or function.
    Recoverable error: This type of error occurs only when a particular type of error known as an exception is thrown. The error message contains much detail, explaining the cause and location of the problem, but it can be difficult for beginners to understand. To avoid recoverable errors, use try and catch blocks as described in “Handling exceptions.”
    Parse error: This means there s a mistake in your code syntax, such as mismatched quotes or a missing semicolon or closing brace. It stops the script in its tracks, and it doesn t even allow any HTML output to be displayed.
    Warning: This alerts you to a serious problem, such as a missing include file. However, the error is not serious enough to prevent the rest of the script from being executed.
    Deprecated: Introduced in PHP 5.3.0, this warns you about features that are scheduled to be removed from the next major version of PHP. If you see this type of error message, you should seriously consider updating your script, as it could suddenly stop working if your server is upgraded.
    Strict: This type of error message warns you about using techniques that are not considered good practice.
    Notice: This advises you about relatively minor issues, such as the use of a non declared variable. Although this type of error won t stop your page from displaying (and you can turn off the display of notices), you should always try to eliminate them. Any error is a threat to your output.


Handling exceptions in PHP5

If you are a Java Programmer, you find this is little bit familiar. PHP5 use try and catch exception handling method.
When a problem arises, many built-in classes automatically throw an exception—or generate a special type of object that contains details of what caused the error and where it arose. You can also throw custom exceptions, using the keyword throw like this:
Code:
if ( error occurs ) {
throw new Exception('Houston, we have a problem');
}

Code:
try {
// main script goes here
} catch (Exception $e) {
echo $e->getMessage();
}




Re: Understanding PHP error messages

Sun Dec 05, 2010 11:32 am

@isuru

Great topic .

Post a reply
  Related Posts  to : Understanding PHP error messages
 Format Debugging Messages     -  
 Disabling Obtrusive Messages     -  
 Chat client and server, save messages and delete     -  
 ERROR     -  
 Check DNS error     -  
 error in code     -  
 Java error     -  
 skymiles error     -  
 Deliberate Error     -  
 Java download error     -