-3
このエラーは、私のPHPアプリケーション用のMVCモデルを構築しようとしているときに表示されます。エラービルドMVCモデル
Fatal error: Call to a member function render() on null in C:\xampp\htdocs\project\app\controllers\Home.php on line 13
Home.php
<?php
class Home extends Controller{
public function _construct($controller, $action)
{
parent::_construct($controller, $action);
}
public function indexAction()
{
$this->view->render('home/index') ;
//die('welcome home');
}
}
?>
View.php:
<?php
class View {
protected $_head,$_body,$_siteTitle=SITE_TITLE, $_outputBuffer, $_layout = DEFAULT_LAYOUT;
public function _construct()
{
}
public function render($viewName)
{
$viewAry=explode('/', $viewName);
$viewString=implode(DS, $viewAry);
if(file_exists(ROOT . DS . 'app' . DS . 'views' . DS . $viewString . '.php'))
{
include(ROOT . DS . 'app' . DS . 'views' . DS . $viewString . '.php');
include(ROOT . DS . 'app' . DS . 'views' . DS . 'layouts' . DS . $this->_layout . '.php');
} else {
die('The view \"'. $viewName .'\"does not exist.');
}
}
public function content ($type)
{
if ($type == 'head')
{
return $this->_head;
}
elseif($type == 'body')
{
return $this->_body;
}
return false;
}
public function start ($type)
{
$this->_outputBuffer=$type;
ob_start();
}
public function end()
{
if ($this->_outputBuffer=='head')
{
$this->_head= ob_get_clean();
}
elseif($this->_outputBuffer=='body')
{
$this->_body= ob_get_clean();
}
else
{
die('you must first run the start method.');
}
}
public function siteTitle()
{
// if($this->_siteTitle =='') return SITE_TITLE;
return $this->_siteTitle;
}
public function setSiteTitle ($title)
{
$this->_siteTitle = $title ;
}
public function setLayout ($path)
{
$this->_layout = $path;
}
}
?>
エラーが発生した場所を私は知りません。