Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 未定义变量编码点火器?_Php_Mysql_Codeigniter - Fatal编程技术网

Php 未定义变量编码点火器?

Php 未定义变量编码点火器?,php,mysql,codeigniter,Php,Mysql,Codeigniter,我的php有问题。我一直在使用codeigniter,以下代码将返回此错误消息: A PHP Error was encountered Severity: Notice Message: Undefined variable: item Filename: views/banner.php Line Number: 37 我的控制器如下所示: public function __construct() { parent::__construct(); $this->a

我的php有问题。我一直在使用codeigniter,以下代码将返回此错误消息:

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: item
Filename: views/banner.php
Line Number: 37
我的控制器如下所示:

public function __construct()
{
    parent::__construct();

    $this->auth->check();

    $this->load->database();
    $this->load->helper('url');
    $this->load->model('banner_model');
}

public function index()
{
    $dados['banner'] = $this->banner_model->recuperar_todos_banners();

    $this->load_view("banner", $dados);
}
我的看法是:

    <? foreach ($banner as $item):?>
       <tr>
          <td><?=$item->chave?></td>
          <td><?=$item->imagem?></td>
          <td><?=$item->descricao?></td>
          <td><?=$item->link?></td>
          <td>
             <button type="button" class="btn btn-danger btn-xs">
                <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
             </button>
          </td>
       </tr>
    <? endforeach; ?>
我使用var_dump测试了这两个变量。这段代码的目的是访问MySQL数据库并将结果存储在数组中。$banner变量工作正常,所有数据都在那里,因此每个位置都被对象占据,每个对象都是一个表行

我知道以前在StackOverflow上有人问过这个问题,但我仍然无法确切地了解到底发生了什么。

查看$banner是否是多维数组,或者在控制器中使用test foreach进行调试,在$item的两个位置都点击一个var_转储。

Me:


是否启用了短标记?如果没有,请执行–Vickel 4分钟前


是否启用了短标记?如果没有,请使用他人发布的答案。我可能应该这么做@托马斯多纳斯波罗内打破了记录-@弗雷德二:你最好!!!否则,这就没有意义了sense@Vickel干杯,我引用了你的评论。