我是 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
加载 View
要加载特定的 View 文件,您将使用以下函数:
$this->load->view('viewfile', $yourdata);
其中 viewfile 是您的 View 文件的名称。注意:不需要指定 .php 文件扩展名,除非您使用的不是 .php。
现在,打开你之前创建的名为 blog.php 的 Controller 文件,并将 echo 语句替换为 View 加载函数:
<?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 访问您的网站,您应该会看到新的 View 。 URL 类似于:
example.com/reservation/details/34
关于php - 无法在 codeigniter 中加载请求的文件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17874060/