When there is a syntax error or an undeclared variable or function it is called PHP code and an error occurs. Thus, we talk about PHP errors when there are problems within the code.
As we shall see in this article, PHP errors: a complete guide, there are several types of errors. Some may interrupt script execution, while others prevent us from getting the result we expect.
When we create a script in PHP, we can run into four types of errors. Let’s see what they are.
Types of PHP errors
Code errors in PHP can be divided into four categories: notice, warning, parse error, and fatal error.
Notice
When such an error occurs in the script code, script execution is not interrupted. An error notice is not a serious error, but this is used to indicate that an error may be present.
The most common case is when an attempt is made to call a variable that has not been defined.
When such an error occurs it will be indicated as “Notice error” or as “PHP Notice”.
Warning
PHP errors of the type “warning” are part of nonfatal errors. Again, as we have just seen for notice errors, the execution of the script is not interrupted.
This type of error can occur, for example, when incorrect parameters are passed to a function or when an attempt is made to call a file that is not present.
Such an error is identified as a “Warning error” or “PHP warning.”
Parse error
In PHP, parse errors are syntax errors, so it is an error in the code such as a typo, the absence of a semicolon or quotation marks.
PHP errors that belong to this category are referred to as “Parse errors” or as “PHP Parse errors.”
Fatal error
Fatal errors are critical errors that interrupt script execution. They can occur during initialization, compilation, or during code execution itself.
These errors are referred to as “Fatal error” or “PHP fatal error.”
PHP error examples
Now that we have take a look at the four main categories of PHP errors, let’s look at examples to help us identify the type of errors.