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 make multiple routes share the same URL structure or URL parameters

How to run an artisan command from a controller

How to hide certain file types from directory listings

How to block an IP address in .htaccess

How to install jpegtran for Linux CentOS

How to install and use jpegoptim on Linux CentOS

How to sort an array in javascript?

How to block IP addresses in Apache by using regular expressions (regex) in .htaccess

How to replace whitespace with a single space

What is the max size, by default, of GET variables?