【发布时间】:2013-01-04 21:34:46
【问题描述】:
以下行是 for each 循环的一部分,该循环遍历从 SQL 查询返回的关联数组。我收到此错误:
可捕获的致命错误:stdClass 类的对象无法转换 串入。
当我为$field2 使用分配变量时会发生错误。但是,如果我将$field2 替换为表中的实际字段名称county_slug,它就可以工作。
如何在下面的语句中使用变量?
echo "<a href='/dealers/3/$geography->$field2/'>$geography->county_short</a>"
【问题讨论】:
-
将
{}中的内容括起来为{$geography->$field2}
标签: mysql arrays variables for-loop