disable smarty notice

2020-06-16 08:35发布

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!

2条回答
看我几分像从前
2楼-- · 2020-06-16 08:51

You should use this: http://www.smarty.net/docs/en/variable.error.reporting.tpl

Just set

$smarty->error_reporting = E_ALL & ~E_NOTICE;
查看更多
够拽才男人
3楼-- · 2020-06-16 08:53

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.

查看更多
登录 后发表回答