PHP E_USER_NOTICE
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.
By. Jacob
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);
Tell us what you think: