Understanding MVC Views in PHP

后端 未结 7 759
生来不讨喜
生来不讨喜 2020-11-22 10:45

I have to seem problems grasping the concept of Views in MVC, they are, according to what I\'ve read, the layer that manages the presentation in the aplication, but many of

7条回答
  •  孤城傲影
    2020-11-22 11:05

    Check this code:

    include_once(ROOT.'/'.'config/config.php');
    
    function __autoload($class_name){
        $lib_path = ROOT . '/' . 'lib/class.'.$class_name . '.php';
        $controller_path = ROOT . '/' . 'controllers/'.str_replace("controller", "", strtolower($class_name)) . '.controller.php';
        $model_path = ROOT . '/' . 'models/'.strtolower($class_name) . '.php';
    
    if(file_exists($lib_path)){
        require_once ($lib_path);
    } else if (file_exists($controller_path)){
        require_once ($controller_path);
    } else if(file_exists($model_path)){
        require_once ($model_path);
    } else {
        throw new Exception("File {$class_name} cannot be found!");
    }
    
    }
    

提交回复
热议问题