簡體   English   中英

Codeigniter視圖不會加載

[英]Codeigniter a view wont load

我在我的控制器中有這個:

class UpdateStats extends CI_Controller{
   public function __construct() {
       parent::__construct();

   }
   function index(){
     $this->load->view('update_stats/index');
    }
}

我的視圖(索引)位於視圖文件夾中的update_stats文件夾中

當我點擊我創建的鏈接時:

 <li id='proxy'><a href="<?php echo base_url();?>index.php/update_stats/">Master Update</a></li>

或者以另一種形式:

  <li id='proxy'><a href="http://localhost/scanner/index.php/update_stats/">Master Update</a></li>

這是我得到的錯誤:

404頁面不存在

未找到您所請求的頁面。

UPDATE我的文件名是:updatestats ..我的類名UpdateStats我嘗試輸入http://localhost/scanner/index.php/updatestats ..我得到404錯誤

文件名: updatestats.php

CLASS NAME: Updatestats.php

URL DESTINATION: http://localhost/scanner/index.php/updatestats/

類:

    class Updatestats extends CI_Controller{
   public function __construct() {
       parent::__construct();

   }
   function index(){
       $this->load->view('templates/header', $data);
            $this->load->view('update_stats/index');
        $this->load->view('templates/footer', $data);

    }
}
enter code here

您的控制器名稱是類聲明中的UpdateStats

class UpdateStats extends CI_Controller{

你正在使用/update_stats/

所以使兩者相似,它可以解決你的問題。

你的道路是錯的。 它應該是

<?php echo base_url();?>index.php/updatestats 

它也不是沒有加載問題的視圖,它甚至找不到控制器

您的控制器名稱是UpdateStats但在您的URL中,您正在調用update_stats update_stats更改為UpdateStats ,看看會發生什么。

不確定,但可能是一些配置問題所以我建議你使用site_url而不是base_url,因為site_url根據你的網站配置創建網址,在你的情況下它將是:

<li id='proxy'><a href="<?php echo site_url('updatestats');?>">Master Update</a></li>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM