繁体   English   中英

错误在codeigniter中的非法字符串偏移量

[英]error illegal string offset in codeigniter

我认为变量“ slug”和“ judul”中存在错误的非法illegal偏移。 你能告诉我什么事吗?

调节器

function index()
{
    $slug = $this->uri->segment(2);
    $this->data['halaman'] = $this->mhalaman->get_profil($slug);

    if (empty($this->data['halaman'])) {
        show_404();
    }
    $this->data['judul'] = $this->data['halaman']['judul'];
    //var_dump($halaman_item['slug']);
    $this->data['orang'] = $this->mlogin->dataPengguna($this->session->userdata('username'));
    $this->data['contents'] = $this->load->view('page', $this->data, true);
    $this->load->view('template/wrapper/mahasiswa/wrapper_content',$this->data);
}

视图

<div class="section ui dropdown link item">
                        <span class="count">Profil</span>
                        <div class="menu">

                            <?php foreach ($halaman as $dt) : ?>
                            <div class="item">
                              <a href="/tkd/index.php/page/<?php echo $dt['slug'] ?>"><?php echo $dt['judul'] ?></a> //line error
                            </div>

                        <?php endforeach; ?>
                        </div>
                      </div>

语气

function get_profil($slug = FALSE)
    {
        if ($slug === FALSE)
        {
            $query = $this->db->get($this->tbl_halaman);
            return $query->result_array();
        }

        $query = $this->db->get_where($this->tbl_halaman, array('slug'=>$slug));
        return $query->row_array();
    }

请帮我该怎么办。 谢谢

应该是echo $dt而不是echo $dt['slug']

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM