鉴于<代码> 冷藏/代码>类别和<代码>View类别,控制者直接分配价值来看待财产,还是更好地将价值分配给控制器内的财产,然后在准备展示这些财产时将其复制到观点?
www.un.org/Depts/DGACM/index_spanish.htm 例类:
class Model
{
public $propertyA;
public $propertyB;
}
www.un.org/Depts/DGACM/index_spanish.htm 例:
class Controller
{
protected $view;
protected $model;
public function __construct()
{
$this->model = new Model();
$this->view = new View();
$this->prepareData();
$this->initView();
}
protected function prepareData()
{
$this->model->propertyA = This is property A. ;
$this->model->propertyB = This is property B. ;
}
protected function initView()
{
$this->view->model = $this->model;
$this->view->display();
}
}
www.un.org/Depts/DGACM/index_spanish.htm 例 观点类别:
class View
{
public $model;
public function display()
{
echo "propertyA = $this->model->propertyA";
echo "propertyB = $this->model->propertyB";
}
}
www.un.org/Depts/DGACM/index_spanish.htm 休业。 我确实使用一种模式,因此请重新考虑你对此的答复。