[英]Php array to string conversion error with SLIM framework
我使用了php框架將變量$ data傳遞到html頁面,循環中的回顯是我的index.php:
$result=$db->query('select * from test');
while ($row=$result->fetch(PDO::FETCH_ASSOC)) {
$data[]=$row;
}
$app->render('form.php',$data));
然后我顯示form.php
foreach ($this->$data as $user) {
echo $user['id']. '-' . $user['name'].'<br>'
}
我得到數組到字符串的轉換錯誤,知道嗎? 我累了var_dump($this->$data);
而不是foreach循環,我得到了相同的錯誤:數組到字符串的轉換
也許$ this-> data而不是$ this-> $ data
foreach ($this->$data as $user) {
echo $user['id']. '-' . $user['name'].'<br>'
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.