An E_WARNING error is not always serious, and often you can safely ignore it. However, it is still best if you try to avoid warnings before they happen.
A warning can be triggered when including a file that does not exist, and when sending HTTP headers after sending HTTP body output. There are also other causes for this error, and most often, it simply happens because there is something the developer overlooked.
To only show E_WARNING errors, you may use the error_reporting function:
To instead show all errors, use E_ALL:
Custom error messages
To trigger a custom warning error, the E_USER_WARNING type should be used:
trigger_error("This situation was not expected, but assuming the developer knows about it, we continue!", E_USER_WARNING);
Note. Only E_USER* types should be used with trigger_error.
Causes for E_WARNING
Trying to send headers after they have been sent earlier in the code will result in:
PHP Warning: Cannot modify header information - headers already sent in...
Another common cause is including trying to include a file that does not exist:
[php7:warn] [pid 8544] [client 127.0.0.1:57390] PHP Warning: include(test.php): failed to open stream: No such file or directory in /var/www/test/test.php on line 3