Home » Php » php – disable smarty notice

php – disable smarty notice

Posted by: admin July 12, 2020 Leave a comment

Questions:

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!

How to&Answers:

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

Just set

$smarty->error_reporting = E_ALL & ~E_NOTICE;

Answer:

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.