為啥什么都沒(méi)顯示……也沒(méi)報(bào)錯(cuò)……說(shuō)好的hello world呢!
<?php class?testController{ function?show(){?//控制器的作用時(shí)調(diào)用模型,并調(diào)用視圖,將模型產(chǎn)生的數(shù)據(jù)傳遞給視圖,并讓相關(guān)視圖去顯示 $testModel?=?new?testModel(); $data?=?$testModel->get(); $testView?=?new?testView(); $testView->$display($data); } } ?>
<?php class?testModel{ function?get(){?//模型的作用時(shí)獲取數(shù)據(jù)并處理返回?cái)?shù)據(jù) return?"Hello?World!"; } } ?>
testView.class.php
<?php class?testView{ function?display($data){?//視圖的作用時(shí)將取得的數(shù)據(jù)進(jìn)行組織,美化等,并最終向用戶(hù)終端輸出 echo?$data; } } ?>
<?php //如果有錯(cuò),include()報(bào)一個(gè)警告 //如果有錯(cuò),require_once()報(bào)一個(gè)嚴(yán)重錯(cuò)誤 require_once('testController.class.php'); require_once('testModel.class.php'); require_once('testView.class.php'); $testController?=?new?testController(); $testController->show(); ?>
2015-09-30
testController里的這個(gè)地方 $testView->$display($data); 寫(xiě)錯(cuò)了,應(yīng)該是$testView->display($data);