0

我正在遵循https://www.codeigniter.com/user_guide/tutorial/static_pages.html上的教程来学习系统。当它说要查看页面时,我收到 HTTP 500 错误。

Codeignitor 已正确安装,并且默认的欢迎页面被拉起。我只是无法弄清楚我在哪里出错了。

class Pages extends CI_Controller {

public function view($page = 'home')
{

    if ( ! file_exists( APPATH . 'views/pages/' . $page . '.php'))
    {
        // Whoops, we don't have a page for that!
        show_404();
    }

    $data['title'] = ucfirst($page); // Capitalize the first letter

    $this->load->view('templates/header', $data);
    $this->load->view('pages/'.$page, $data);
    $this->load->view('templates/footer', $data);

}
4

2 回答 2

0

APPPATH不是APPATH.

于 2013-06-07T19:56:54.727 回答
0

就像已经回答的那样,它是APPPATH.

APPPATH 是一个包含字符串的常量,如果从控制器调用该字符串,则返回“application/”

尝试这个:

public function view($page = 'home')
{

    if ( ! file_exists( APPPATH . "views/pages/{$page}.php"))
    {
        // Whoops, we don't have a page for that!
        show_404();

    } else {

    $data['title'] = ucfirst($page); // Capitalize the first letter

    $this->load->view('templates/header', $data);
    $this->load->view("pages/{$page}", $data);
    $this->load->view('templates/footer', $data);

    }
}
于 2013-06-07T23:50:05.477 回答