Php 在CodeIgniter中找不到错误类控制器
您好,我在CodeIgniter中发现Php 在CodeIgniter中找不到错误类控制器,php,codeigniter,class,controller,Php,Codeigniter,Class,Controller,您好,我在CodeIgniter中发现控制器未找到错误。这是我的控制器代码 <?php class HelloWorld extends Controller { function HelloWorld() { parent::Controller(); } function index() { $this->load->view('index_view'); } function
控制器
未找到错误。这是我的控制器代码
<?php
class HelloWorld extends Controller
{
function HelloWorld()
{
parent::Controller();
}
function index()
{
$this->load->view('index_view');
}
function hello()
{
$this->load->view('hello_view');
}
}
?>
这是视图代码:
你好,很高兴见到你代码>
当它执行时,我有以下错误:
致命错误:在第2行的D:\wamp\www\CodeIgniter\u 2.0.2\application\controllers\helloworld.php中找不到类“Controller”
有人能告诉我为什么会出现此错误吗?请确保您的控制器扩展了父控制器类,并检查您的文件名
<?
class Helloworld extends CI_Controller {
function index()
{
$this->load->view('index_view');
}
function hello(){
$this->load->view('hello_view');
}
}
?>
从CodeIgniter 2.x开始,所有核心类都添加了前缀。检查一下
为所有核心类添加了CI前缀。
对于CodeIgniter 2.x
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class HelloWorld extends CI_Controller
{
function __construct()
{
parent::__construct();
}
function index()
{
$this->load->view('index_view');
}
function hello()
{
$this->load->view('hello_view');
}
}
我遇到了与您相同的问题,我通过用CI_Controller替换父类扩展行中的Controller一词尽可能简单地解决了这个问题,这可能是我的工作,下面是您代码中的解决方案
<?php
class HelloWorld extends CI_Controller{
function HelloWorld() {
parent::Controller();
}
function index() {
$this->load->view('index_view');
}
function hello() {
$this->load->view('hello_view');
}
}
?>
您的代码将执行真的比。。。我很困惑
<?php
class HelloWorld extends CI_Controller{
function HelloWorld() {
parent::Controller();
}
function index() {
$this->load->view('index_view');
}
function hello() {
$this->load->view('hello_view');
}
}
?>