2013-07-26 76 views
3

我是CodeIgniter的新手。我遇到了这个问题。无法在codeigniter中加载请求的文件错误

Unable to load the requested file: 
http://localhost/grf_new/index.php/reservation/details/34/.php 

的代码看起来像这样

$this->load->view(base_url().index_page().'/reservation/details/'.$userid.'/', $data); 
+0

有没有什么办法来消除被自动添加“.PHP”。 – user2621440

+0

在文件夹视图/ reservation/details/34.php中是否有文件?你正在加载视图文件没有URL – Bora

+0

没有...实际上预订是类,细节是功能和34是该功能的参数 – user2621440

回答

2

不要使用此

$this->load->view('test/test', $data); 

如果在创建视图文件夹添加文件base_url()

加载文件文件夹这样的

application/views 

test/test.php 

//--------------------- 

//If you want to read the URL use file_get_contents() function 
+0

更多参考http://ellislab.com/codeigniter/user-guide/general/views.html – Sundar

+0

没有帮助,仍然得到错误 – NIMISHAN

3

笨文档:http://ellislab.com/codeigniter/user-guide/general/views.html

加载查看

要加载您将使用以下功能的特定视图文件:

$this->load->view('viewfile', $yourdata); 

哪里viewfile是您的视图文件的名称。注意:.php文件扩展名不需要指定,除非使用.php以外的内容。

现在,打开你早些时候所作称为blog.php的控制器文件,并与视图载入函数替换echo语句:

<?php 
class Reservation extends CI_Controller { 

    function details($id) 
    { 
     $this->data['user_info'] = $this->user_model->getUser($id)->result(); 
     $this->load->view('userdetails', $this->data); 
    } 
} 
?> 

如果您使用的URL访问你的网站,你没有更早你应该看到你的新观点。该URL类似于此:

example.com/reservation/details/34 
1

这应该工作(犯规测试):

$this->load->view('reservation/details/'.$userid, $data); 
+0

这里预订是控制器类,所以你如何在视图中调用它? – NIMISHAN