Common_Model.php exists but does not declare the Common_Model class

I tried to check all the names. It works fine in php 5.3 but doesn't work in php 5.5

An unrelated exception was found

Type: RuntimeException

Message: C: \ xampp \ htdocs \ project \ application \ models / Common_Model.php exists, but does not declare the Common_Model class

File Name: C: \ xampp \ htdocs \ project \ system \ core \ Loader.php

Line Number: 306

Backtrace:

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

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

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

Common_Model.php contains:

 <? 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

An unrelated exception was found

Type: RuntimeException

Message: C: \ xampp \ htdocs \ project \ application \ models / Common_model.php exists, but does not declare the Common_model class

File Name: C: \ xampp \ htdocs \ project \ system \ core \ Loader.php

Line Number: 306

Backtrace:

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

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

+5
source share
6 answers

Your web server is not like php shorthand statement. Just change <? on <?php and everything should be fine.

+5
source

try it

file name should be Common_model.php

and inside this

 <?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 the controller

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

Try changing your model name to Common_model.php and the class name to Common_model.

+1
source

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

 class Common_model extends CI_Model 

This error most likely occurred as a result of using a duplicated or sealed class name in Common_model.php

Greetings

+1
source

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

0
source

I think your model file name and controller file name are the same. Please make it different and check. It works great for me.

0
source

Source: https://habr.com/ru/post/1239786/


All Articles