初始化

This commit is contained in:
2026-08-08 18:28:49 +08:00
parent 9bef4420e0
commit f082037a6e
854 changed files with 217171 additions and 11 deletions
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace core\base;
/**
* 视图类
*/
class View
{
protected $_controller;
protected $_action;
protected $_vars = array();
public function __construct($controller, $action)
{
$this->_controller = $controller;
$this->_action = $action;
}
// 分配变量
public function assign($name, $value)
{
$this->_vars[$name] = $value;
}
// 渲染视图
public function render()
{
extract($this->_vars);
$viewFile = APP_PATH . 'app/views/' . $this->_controller . '/' . $this->_action . '.php';
if (is_file($viewFile)) {
include $viewFile;
} else {
exit('视图文件不存在');
}
}
}