Beamtic's logo

Share via:


The E_USER_NOTICE error type is used when triggering errors under specific circumstances, such as when we want to inform someone that they are using a feature in our code in an unintended way.


Edited: 2020-09-24 12:33

The E_USER_NOTICE error type can be used with the trigger_error function to send a user-defined error; it may be used for errors that might be intentionally caused by a user of a library or piece of code that you are developing.

PHP will tolerate certain bad-practices, such as using variables before declaring them, and sometimes this may even be intentional by the developer. The problem is that if there is a lot of notices generated, it can clutter the error logs and make them harder to interpret; because of this, it is recommended to always fix notices.

The E_USER_NOTICE type can be triggered when a user of your code uses it in unintended ways, but you still want to allow them to continue.

Note. For most purposes, throwing an exception is probably a better alternative than triggering PHP errors.

To trigger a E_USER_NOTICE error, you may use the trigger_error function:

trigger_error("You probably should not be using the feature this way, but I will allow you to continue if you know what you are doing.", E_USER_NOTICE);


  1. E_STRICT will only show you warnings about deprecated PHP features and things that might not be future-proof, it will not show you notices or warnings; E_ALL includes everything, and that includes E_STRICT messages.
  2. Developers can trigger custom PHP error messages using the trigger_error function; but throwing an exception is often better.
  3. How to show or hide error messages in PHP. There are several ways to do this; from within the PHP scripts themselves, from php.ini, or from changing Apache configuration files.
  4. How to create a custom error handler for PHP that handles non-fetal errors.
  5. The fread function can be dangerous when used inside a loop in PHP, find out how to secure it in this article.

More in: PHP Errors