Common_Model。php存在,但不声明类Common_Model。

时间:2022-08-30 00:05:39

I tried checking all the names. It is working fine in php 5.3 but not working in php 5.5

我试着检查所有的名字。它在php 5.3中运行良好,但在php 5.5中不起作用。

An uncaught Exception was encountered

遇到了一个未捕获的异常。

Type: RuntimeException

类型:RuntimeException

Message: C:\xampp\htdocs\project\application\models/Common_Model.php exists, but doesn't declare class Common_Model

项目信息:C:\ xampp \根\ \程序\ / Common_Model模型。php存在,但不声明类Common_Model。

Filename: C:\xampp\htdocs\project\system\core\Loader.php

文件名:C:\ xampp \根\ \ system \ \ Loader.php核心项目

Line Number: 306

行号:306

Backtrace:

回溯:

File: C:\xampp\htdocs\project\application\controllers\Auth.php Line: 7 Function: __construct

项目文件:C:\ xampp \根\ \程序\控制器\身份验证。php行:7函数:__construct。

File: C:\xampp\htdocs\project\index.php Line: 292 Function: require_once

项目文件:C:\ xampp \根\ \指数。php行:292函数:require_once。

In the message, I can see an unexpected backslash in front of Common_Model.php. Message: C:\xampp\htdocs\project\application\models/Common_Model.php exists, but doesn't declare class Common_Model

在消息中,我可以在Common_Model.php前面看到一个意外的反斜杠。项目信息:C:\ xampp \根\ \程序\ / Common_Model模型。php存在,但不声明类Common_Model。

Common_Model.php contains:

Common_Model。php包含:

<? if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Common_Model extends CI_Model {


        public function __construct()
        {
                // Call the CI_Model constructor
                parent::__construct();
        }
        .
        .
        .
        .

EDIT

编辑

I just changed Common_Model.php to Common_model.php and still getting the same error

我只是改变了Common_Model。php Common_model。php和仍然得到相同的错误。

An uncaught Exception was encountered

遇到了一个未捕获的异常。

Type: RuntimeException

类型:RuntimeException

Message: C:\xampp\htdocs\project\application\models/Common_model.php exists, but doesn't declare class Common_model

项目信息:C:\ xampp \根\ \程序\ / Common_model模型。php存在,但不声明类Common_model。

Filename: C:\xampp\htdocs\project\system\core\Loader.php

文件名:C:\ xampp \根\ \ system \ \ Loader.php核心项目

Line Number: 306

行号:306

Backtrace:

回溯:

File: C:\xampp\htdocs\project\application\controllers\Auth.php Line: 7 Function: __construct

项目文件:C:\ xampp \根\ \程序\控制器\身份验证。php行:7函数:__construct。

File: C:\xampp\htdocs\project\index.php Line: 292 Function: require_once

项目文件:C:\ xampp \根\ \指数。php行:292函数:require_once。

6 个解决方案

#1


6  

Your web server doesn't like php shorthand operator. Just change <? to <?php and it should be all good.

您的web服务器不喜欢php简化操作符。只改变< ?< ?php和它应该都很好。

#2


5  

Try this

试试这个

file name should be Common_model.php

文件名应该是Common_model.php。

and inside that

和内

<?php

    if (!defined('BASEPATH'))
        exit('No direct script access allowed');

    class Common_model extends CI_Model {

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

        public function getUser()
        {
            # Your query goes here
        }

    }

In Controller

在控制器

$this->load->model('Common_model'); # Load Model
$result = $this->Common_model->getUser(); # Access the model function

#3


1  

Try to change the name of your model to Common_model.php and the name of the class to Common_model.

尝试将模型的名称更改为Common_model。php和Common_model的类名。

#4


1  

Check the class name in Common_model.php it should be like this

检查Common_model中的类名。php应该是这样的。

class Common_model extends CI_Model

This error most likely happened as result of using duplicated or misspelled class name in Common_model.php

这个错误很可能是在Common_model.php中使用重复或拼写错误的类名造成的。

Cheers

干杯

#5


0  

Check the name of model. For example, if the name of the model is Common_model.php and you write in the file Comn_model extends CI_Model, we get this error.

检查模型的名称。例如,如果模型的名称是Common_model。php和你在文件Comn_model扩展了CI_Model,我们得到这个错误。

#6


0  

I think your model file name and controller files name is same. please make it differ and check. It is working fine for me.

我认为您的模型文件名和控制器文件名称是相同的。请让它有区别和检查。这对我来说没问题。

#1


6  

Your web server doesn't like php shorthand operator. Just change <? to <?php and it should be all good.

您的web服务器不喜欢php简化操作符。只改变< ?< ?php和它应该都很好。

#2


5  

Try this

试试这个

file name should be Common_model.php

文件名应该是Common_model.php。

and inside that

和内

<?php

    if (!defined('BASEPATH'))
        exit('No direct script access allowed');

    class Common_model extends CI_Model {

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

        public function getUser()
        {
            # Your query goes here
        }

    }

In Controller

在控制器

$this->load->model('Common_model'); # Load Model
$result = $this->Common_model->getUser(); # Access the model function

#3


1  

Try to change the name of your model to Common_model.php and the name of the class to Common_model.

尝试将模型的名称更改为Common_model。php和Common_model的类名。

#4


1  

Check the class name in Common_model.php it should be like this

检查Common_model中的类名。php应该是这样的。

class Common_model extends CI_Model

This error most likely happened as result of using duplicated or misspelled class name in Common_model.php

这个错误很可能是在Common_model.php中使用重复或拼写错误的类名造成的。

Cheers

干杯

#5


0  

Check the name of model. For example, if the name of the model is Common_model.php and you write in the file Comn_model extends CI_Model, we get this error.

检查模型的名称。例如,如果模型的名称是Common_model。php和你在文件Comn_model扩展了CI_Model,我们得到这个错误。

#6


0  

I think your model file name and controller files name is same. please make it differ and check. It is working fine for me.

我认为您的模型文件名和控制器文件名称是相同的。请让它有区别和检查。这对我来说没问题。