具有关联数组意外的"="的Smarty对象函数,应预期为“",“",",“)"' [英] Smarty Object Function with Associative Array Unexpected "=>", expected one of: "","" , ")"'

查看:89
本文介绍了具有关联数组意外的"="的Smarty对象函数,应预期为“",“",",“)"'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到Smarty将PDO对象传递给Smarty的问题,只是不喜欢=>.有解决这个问题的技巧吗?

I am having a problem with Smarty passing a PDO Object to Smarty it just doesn't like =>. Is there a trick to get around this problem?

这是他的错误:

{assign var='brgdatas' value="{$brgObj->fetchOneBrg(array('id'=>{$ststres[ststval].to_id}'))}"}" - Unexpected "=>", expected one of: "","" , ")

这是我正在使用的代码:

Here is the code I am working with:

{section name=ststval loop=$ststres}

{if $ststres[ststval].type == 2}

{assign var='brgdatas' value="{$brgObj->fetchOneBrg(array('id'=>{$ststres[ststval].to_id}'))}"}

正确答案更新:

是在关联数组之间添加[],并删除引号.

Is to add [] between the associative array and remove the quotes like so.

{assign var='brgdatas' value=$brgObj->fetchOneBrg(['id'=>$ststres[ststval].to_id])}

推荐答案

删除最后一个单撇号和value属性内的键{}

Remove the last single apostrophe and the keys {} inside the value attribute

value="{$brgObj->fetchOneBrg(array('id'=>{$ststres[ststval].to_id}'))}"
       ^                                 ^                        ^  ^

这篇关于具有关联数组意外的"="的Smarty对象函数,应预期为“",“",",“)"'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆