MVC(PHP)

Controller

<?php
class testController{
    //控制器的作用是調用模型並調用視圖,將模型產生的數據傳遞給視圖,並讓相關視圖去顯示
    function show(){
       /* $testModel = new testModel();
        $data = $testModel->get();
        $testView = new testView();
        $testView->display($data);*/

       $testModel = M('test');
       $data = $testModel->get();
       $testView = V('test');
       $testView->display($data);
    }
}
?>

Model

<?php
class testModel{
    function get(){
        return "hello world";
    }
}
?>

view

<?php
class testView{
    function display($data){
        echo $data;
    }
}
?>

function

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章