0

I am trying to do an error suppression without the error_reporting(NULL) while adding values to a variable that may not be set yet. For example:

{$var.1 = $var.1 + 10}

In this case $var.1 isn't defined yet, in PHP I can use @ infront of the line to ignore error. How can i do this on Smarty?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Galfau
  • 82
  • 1
  • 1
  • 9
  • possible duplicate of [disable smarty notice](http://stackoverflow.com/questions/6789102/disable-smarty-notice) – Daniel Williams Jul 10 '14 at 22:17
  • I dont want to use error_reporting this isnt a duplicate, I dont want to ignore all errors on the template i just want to ignore that explicit error. – Galfau Jul 10 '14 at 22:17

1 Answers1

0

If it's ok you fetch code to PHP, you can do it this way:

$errorReportingLevel = $smarty->error_reporting;
$smarty->error_reporting = 0;
echo $smarty->fetch('index.tpl');
$smarty->error_reporting = $errorReportingLevel;
echo $smarty->fetch('index.tpl');

In the first one call you won't get any warnings and in the second one you will.

As far as I know there is no other way. In addition you should really consider removing this warning. Code should be written the way no notices or warnings are displayed - both in PHP ans in Smarty.

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291