注意:未定义的偏移量:聪明的0

时间:2012-12-27 17:41:57

标签: smarty notice

我收到以下通知,并想澄清:

Notice: Undefined offset: 0 in /homepages/40/d35550088/htdocs/smarty/templates_c/
ef666588706a0451c86287e631024054e2f40226.file.list.tpl.php on line 434 

Notice: Undefined offset: 1 in /homepages/40/d35550088/htdocs/smarty/templates_c/
ef666588706a0451c86287e631024054e2f40226.file.list.tpl.php on line 434 

Notice: Undefined offset: 2 in /homepages/40/d35550088/htdocs/smarty/templates_c/
ef666588706a0451c86287e631024054e2f40226.file.list.tpl.php on line 434  

Notice: Undefined offset: 9 in /homepages/40/d35550088/htdocs/smarty/templates_c/
ef666588706a0451c86287e631024054e2f40226.file.list.tpl.php on line 434 

编译的tpl中的代码行是:

<?php if ($_smarty_tpl->tpl_vars['TablesLinked']->value[$_smarty_tpl->getVariable('smarty')->value['section']['i']['index']]){?>

这是未编译的行:

{if $TablesLinked[i]}

上面的一行开始了这一部分:

{section name=i loop=$NumberFields}

我是否必须更改起始索引,因为偏移意味着错误的索引? TablesLinked不会出现在每个字段中,因为字段由链表和普通字段组成,这就是我使用if子句的原因。

我希望你能提供帮助。

1 个答案:

答案 0 :(得分:1)

虽然这是一个非常好的做法,在开发阶段设置error_reporting到E_ALL并试图消除所有通知,但我个人不会担心这些消息。它只是在循环期间找不到指定索引上的元素。在任何情况下,如果您坚持取消通知,您可以更改

{if $TablesLinked[i]}

{if isset($TablesLinked[i]) && $TablesLinked[i]}