我尝试使用 CodeIgniter 编写站点,但我遇到了 PHP 方面的问题。我敢肯定,就是这么简单,不会错的。但我不知道来自 的错误,只是 CodeIgniter 的新手 :)
<html>
<head>
<title><?=$page_title?></title>
</head>
<body>
<?php foreach($result as $row):?>
<h3><? echo $row->title; ?></h3>
<p><? echo $row->text; ?></p>
<?php endforeach;?>
</body>
</html>
我有一个来自这个文件的错误:
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/helloworld_view.php
Line Number: 6
预先感谢您阅读本文:)
最佳答案
尝试 foreach($result->result() as $row)
- 您可能正在尝试遍历 Codeigniter 的事件记录返回的对象。
关于PHP - CodeIgniter - 为 foreach() 提供的参数无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2577968/