Загрузка...

Common PHP error handling mistakes

Error handling is an important aspect of programming. If a PHP scripts lacks error handling then it cannot be consider as a professional coding. Let us share some common PHP error handling mistakes.

1. Parse error.
A parse error occurs when the syntax in coding is not familiar to PHP interpreter.
As for example, we are trying to include a file file11.php, suppose this file does not exists. PHP stops execution and throws necessary error message.
include "file11.php";

2. Failed to open stream: no such file or directory.
This type of error occurred if file db.php or directory db does not exists, or if there is a typo mismatch, or if there is insufficient permission.
include "./db/db.php";

3. Cannot re-declare function.
This type of error occurred if any function declared more than once.
function to_do_list()
{
}
function to_do_list()
{
}

4. Uncaught error: Undefined constant.
This error occurs when we are trying to access a constant that does not define at all.

5. Fatal error: Class not found.
This error occurs when a used class in the code cannot be located anywhere.

6. Fatal error: Uncaught Error: Call to undefined function.
This error occurs when we are calling a function which is not defined yet.

7. Fatal error: Uncaught Error: Cannot use object of type class as array.
This error occurs when an object is attempting to treat as an array.

8. Fatal error: Uncaught ArgumentCountError: Too few arguments to function.
Number of parameters are less than expected in a function.

9. Warning: Undefined Variable.
Trying to use a variable which is not yet defined.

10. Warning: Cannot Modify Header Information - Headers Already Sent.
Something is output without setting the HTTP headers.

11. Warning: Undefined Array Key "...".
Trying to access an array element using a key which does not exists.

12. Warning: Attempt to Read Property "..." on String or Array.
Trying to accees a property on a variable that is not an object.

Видео Common PHP error handling mistakes канала PHP Explained
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять