I am having a problem on my MVC framework. Here is my loadModel() method inside the main controller:
public function loadModel($name) {
$path = 'models/' . $name . '_Model.php';
if (file_exists($path)) {
require $path;
$modelName = $name . '_Model';
$this->model = new $modelName;
}
}
As you can see, when i try to load a controller, it automatically loads a model with the same name + _model.php.
I do not have any problem, when I use wamp or xampp, but, when I uploaded it in my website, it says "Undefined property" on every model. That means the model is not loaded. I know the problem is in there…
Is that some kind of an error in php.ini file of the server? Or maybe it because of different PHP versions?
Windows is not case sensitive, i.e. Model.php and model.php are the same as far as windows is concerned. ON unix/linux however (which I’m assuming your website server is) the file system IS case sensitive.
Basically, check your files names – if you’re trying to load
$name_Model.phpbut the file is$name_model.phpit’s going to fail when you upload it.