'disable smarty notice
I would like to disable smarty-s notices.
This exactly:
Notice: Undefined variable: xy
Because I know that some variables are undefined and in some cases I don't even want to define them.
BUT I don't want to disable other PHP notices.
Thanks for help!
Solution 1:[1]
You should make your checks on the variables and make sure they are defined and set before using. Removing the Notices and Warnings enhance the performance of your application.
When your application or website is published you should add the following condition to avoid errors from appearing to your customers:
error_reporting(E_ERROR || E_WARNING);
Only warning and Errors will appear.
Solution 2:[2]
Since Smarty4 there is a new method:
$smarty->setErrorReporting(E_ALL & ~E_NOTICE);
$smarty->muteUndefinedOrNullWarnings();
See https://github.com/smarty-php/smarty/blob/v4.0.0/CHANGELOG.md
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Echilon |
| Solution 2 | Wolfgang Blessen |
