“无法加载请求的文件” [英] "Unable to load the requested file"

查看:34
本文介绍了“无法加载请求的文件”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在XAMPP 1.7.7上使用CodeIgniter 2.0.3,我得到的错误代码为:无法加载请求的文件:home.php

Using CodeIgniter 2.0.3 on XAMPP 1.7.7 I have code where I get the error as: Unable to load the requested file: home.php

home.php 代码如下,存储在中。/ci2/application/controllers

class Home extends CI_Controller {

    function Home()
    {
        parent::__construct();   
    }

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


推荐答案

使用它时,请注意:


  1. 控制器的名称为 home.php

名为 home.php 的文件必须存在于 ci / views

File named home.php must be present in ci/views

如果视图文件夹中的文件扩展名不是php,例如其html。
然后使用以下命令加载它: $ this-> load-> view('home.html');

Incase file extention in view folder is not php eg like its html. then load it using : $this->load->view('home.html');

您需要从外部调用的函数必须是公共的因此,请使其:
public function index(){...}

the function u need to call from outside must be public So make it: public function index() {... }

因为您正在调用Home类的构造函数。像这样称呼:

as u are calling the constructor for the class Home. Call it like:

class Home extends CI_Controller {

function __construct()
{
    parent::__construct();   
}

public function index()
{
    $this->load->view('home');
}

现在它将正常工作!

这篇关于“无法加载请求的文件”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆