From e741063667904b391a2a444f441224389ff798ee Mon Sep 17 00:00:00 2001 From: Aran Wilkinson Date: Thu, 11 Jul 2013 22:46:26 +0100 Subject: [PATCH 1/3] Expanded Errors section to cover more --- _posts/07-02-01-Errors.md | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/_posts/07-02-01-Errors.md b/_posts/07-02-01-Errors.md index dd4daeb..9e89952 100644 --- a/_posts/07-02-01-Errors.md +++ b/_posts/07-02-01-Errors.md @@ -1,11 +1,36 @@ ---- -isChild: true +--- +isChild: true --- ## Errors {#errors_title} -PHP has several levels of error severity. The three most common types of messages are errors, notices and warnings. These have different levels of severity; `E_ERROR`, `E_NOTICE`, and `E_WARNING`. Errors are fatal run-time errors and are usually caused by faults in your code and need to be fixed as they'll cause PHP to stop executing. Warnings are non-fatal errors, execution of the script will not be halted. Notices are advisory messages caused by code that may or may not cause problems during the execution of the script, execution is not halted. +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. -Another type of error message reported at compile time is the `E_STRICT` message, these messages are used to suggest changes to your code to help ensure best interoperability and forward compatibility for your code. +### Error Severity -* [Predefined Constants for Error Handling](http://www.php.net/manual/en/errorfunc.constants.php) \ No newline at end of file +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. + +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]. + +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. + +* [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. + +* [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) +* [ErrorException Class][errorexception] +* [Reporting][errorreport] + +[errorexception]: http://php.net/manual/en/class.errorexception.php +[errorreport]: /#error_reporting From 25d81eb23d7dc726df3e771baebbb179d95bd597 Mon Sep 17 00:00:00 2001 From: Aran Wilkinson Date: Fri, 12 Jul 2013 06:34:10 +0100 Subject: [PATCH 2/3] Forced Word Wrap Signed-off-by: Aran Wilkinson --- _posts/07-02-01-Errors.md | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/_posts/07-02-01-Errors.md b/_posts/07-02-01-Errors.md index 9e89952..dcbca74 100644 --- a/_posts/07-02-01-Errors.md +++ b/_posts/07-02-01-Errors.md @@ -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) From 6fcb597b6e8b89ebb135e9b77a0310366d01e55f Mon Sep 17 00:00:00 2001 From: Aran Wilkinson Date: Fri, 12 Jul 2013 07:05:20 +0100 Subject: [PATCH 3/3] Reworded Error Control Operator and ErrorExceptions Signed-off-by: Aran Wilkinson --- _posts/07-02-01-Errors.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/_posts/07-02-01-Errors.md b/_posts/07-02-01-Errors.md index dcbca74..bbfc67f 100644 --- a/_posts/07-02-01-Errors.md +++ b/_posts/07-02-01-Errors.md @@ -31,17 +31,21 @@ 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. The use of this operator -is not advised +is not advised and should never be used, using this operator is like admitting your code is bad and can fail over * [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 class extends the `Exception` +class. This is a common practice and by passing errors off as Exceptions in development you can handle them better than +the usual result. By passing these Errors as Exceptions and not trying to catch them in Development the hope is that +you'll catch the Error and hopefully this will allow you to deal with the issue before it becomes a problem in a +Production Environment. +More information on this and details on how to use `ErrorException` with Error Handling can be found at +[ErrorException Class][errorexception]. +* [Error Control Operators](http://php.net/manual/en/language.operators.errorcontrol.php) * [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) * [ErrorException Class][errorexception]