I currently have all errors enabled for my site:
error_reporting(E_ALL);
However, in PHP 8.1, some functions are now deprecated:
PHP Notice: Function date_sunset() is deprecated in index.php on line 14
Due to current requirements, I am unable to update the line to the non-deprecated alternative.
Is there a way to disable error reporting of deprecations just for this single line?
3
Answers
As a workaround, you can wrap your deprecated line like this:
Or if you wish to simply toggle the deprecated flag, use this:
The proposed workaround is only good until the function is removed, then it will only be fatal at some point whenever the function is removed, and a forced change will be imminent anyway.
Why not try to use what PHP’s own API suggests?:
See date_sun_info() … there are less parameters though, depending upon what you may have used previously with date_sunset().
You can add
@
infront of your deprecated function. With the@
you suppress the PHP error messages that would otherwise have been thrown at this point.@functionName(...)