Skip to content

Commit

Permalink
Forced Word Wrap
Browse files Browse the repository at this point in the history
Signed-off-by: Aran Wilkinson <[email protected]>
  • Loading branch information
aranw committed Jul 12, 2013
1 parent e741063 commit 25d81eb
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions _posts/07-02-01-Errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,43 @@ isChild: true

## Errors {#errors_title}

PHP Errors differ to Exceptions in that they, Errors can halt the execution of your script depending on the level of severity. Exceptions on the other hand can be caught using `try catch` statements.
PHP Errors differ to Exceptions in that they, Errors can halt the execution of your script depending on the level of
severity. Exceptions on the other hand can be caught using `try catch` statements.

### Error Severity

PHP's built in error reporting and logging, allows for different levels of reporting via the use of Predefined Constants. The three main constants are `E_ERROR`, `E_NOTICE`, and `E_WARNING`.
PHP's built in error reporting and logging, allows for different levels of reporting via the use of Predefined
Constants. The three main constants are `E_ERROR`, `E_NOTICE`, and `E_WARNING`.

The different levels of error severity have different meanings. The three most common types of messages are Errors, Notices and Warnings. Errors are fatal run-time Errors and are usually caused by faults in your code and need to be fixed as they'll cause execution to be halted. Warnings are non-fatal errors, execution of the script will continue and dependant on settings the user may or not may see the Warning message. Notices are advisory messages caused by code that may or may not cause problems during script execution, execution is not halted and again depending on settings the user may or not see the Notice message.
The different levels of error severity have different meanings. The three most common types of messages are Errors,
Notices and Warnings. Errors are fatal run-time Errors and are usually caused by faults in your code and need to be
fixed as they'll cause execution to be halted. Warnings are non-fatal errors, execution of the script will continue
and dependant on settings the user may or not may see the Warning message. Notices are advisory messages caused by
code that may or may not cause problems during script execution, execution is not halted and again depending on
settings the user may or not see the Notice message.

Another type of Error Message reported at compile time are `E_STRICT` messages, these messages are used to suggest
changes to your code to help ensure best interoperability and forward compatibility for your code.

### Changing PHP's Error Reporting Behaviour

Error Reporting can both be changed using PHP settings and PHP function calls. Using the built in PHP function `error_reporting()` you can set the level of errors for the duration of the script execution by passing one of the Predefined Constants. For more information on this relating to application environments check out the [Error Reporting][errorreport].
Error Reporting can both be changed using PHP settings and PHP function calls. Using the built in PHP function
`error_reporting()` you can set the level of errors for the duration of the script execution by passing one of the
Predefined Constants. For more information on this relating to application environments check
out the [Error Reporting][errorreport].

As well as setting the level of error reporting during script execution you can also suppress Errors using the Error Control Operator `@` by putting this operator at the beginning an expression.
As well as setting the level of error reporting during script execution you can also suppress Errors using the
Error Control Operator `@` by putting this operator at the beginning an expression. The use of this operator
is not advised

* [Error Control Operators](http://php.net/manual/en/language.operators.errorcontrol.php)

### Error Exceptions

Optionally you can throw your Errors as Exceptions using the `ErrorException` class, this extends the `Exception` class. More information on this and details on how to use `ErrorException` can be found at [ErrorException Class][errorexception]. This is a common practice but it is not an advised practice. Errors are used to faults and potential issues in your code that should be corrected.
Optionally you can throw your Errors as Exceptions using the `ErrorException` class, this extends the `Exception`
class. More information on this and details on how to use `ErrorException` can be found at
[ErrorException Class][errorexception]. This is a common practice but it is not an advised practice.
Errors are used to faults and potential issues in your code that should be corrected.

* [Predefined Constants for Error Handling](http://www.php.net/manual/en/errorfunc.constants.php)
* [error_reporting](http://www.php.net/manual/en/function.error-reporting.php)
Expand Down

0 comments on commit 25d81eb

Please sign in to comment.