What are the main error types in PHP

PHP: What are the main error types in PHP

There are 3 main types of errors: Notices (not very important), Warnings (quite important), and Fatal (so important that the script will halt).

(Please don't ignore Notices just because I said they're not important. It was only to give a comparison between those three. There is often very important information in the Notice errors)

Notices (E_USER_NOTICE) - These are non-critical errors that do not stop further execution of the script (by default). If you try to use a variable that has not been set, you will get an E_USER_NOTICE notice error, but the script will (in default PHP settings) continue to run.

Warnings (E_USER_WARNING) - These are similar to notices, but more important. The script will still run (with default PHP settings), however, you should really pay attention to them. A warning error would be shown (/logged) for things such as attempting to use include() on a file that does not exist.

Fatal Errors (E_ERROR, or E_CORE_ERROR if PHP cannot initialise) - if your scripts encounter a fatal error, it will stop execution. A fatal error comes from doing things such as calling a function that does not exist, or calling require() for a file that does not exist.

webdevetc profile pic

I am a 29 year old backend web developer from London, mostly focusing on PHP and Laravel lately. This (webdevetc.com) is my blog where I write about some web development topics (PHP, Laravel, Javascript, and some server stuff). contact me here.


Comments and discussion about What are the main error types in PHP

Found this interesting? Maybe you want to read some more in this series?

Or see other topics in the PHP language

Or see other languages/frameworks:
PHP Laravel Composer Apache CentOS and Linux Stuff WordPress General Webdev and Programming Stuff JavaScript
Or see random questions

How do you launch the PHP interactive shell?

How to replace values in a string, in JS

How can you check if a variable is alphanum (alphanumeric, letters and numbers only) in PHP?

How to set custom HTTP headers in Apache (by editing .htaccess)

How to block IPv6 IP addresses in .htaccess

Why should you update APP_URL from from http://localhost?

How to check if a string contains a certain substring?

What is the null coalescing operator in PHP7?

PHP Date commonly used formats

What is snake case?