我是 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);
我是 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);
Codeigniter 文档: 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
不要添加base_url()
使用这个加载文件
$this->load->view('test/test', $data);
如果您的文件夹像这样,请在视图文件夹中创建一个文件
application/views
test/test.php
//---------------------
//If you want to read the URL use file_get_contents() function
这应该有效(不测试):
$this->load->view('reservation/details/'.$userid, $data);