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
webdevetc

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.



More...


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 to find out what version of Laravel you are using?

Point all requests to one PHP file

How to make multiple routes share the same URL structure or URL parameters

How to block multiple IP addresses in .htaccess

How to view all installed PHP modules?

How to return JSON data to the user in Laravel?

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

How do you run a PHP script from the command line?

301 Redirect a single URL in .htaccess to a new location

What is Bubble sort, and how to write an implementation of it in PHP