文件还在测试中

This commit is contained in:
2026-08-08 15:53:53 +08:00
parent 5f1e7adb64
commit 8101177cb5
241 changed files with 18074 additions and 22 deletions
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace Core;
class View
{
public static function buffer(string $view, array $data = []): string
{
$file = BASE_PATH . '/app/Views/' . str_replace('.', '/', $view) . '.php';
if (!is_file($file)) {
throw new \Exception("视图不存在: $view");
}
ob_start();
extract($data, EXTR_SKIP);
include $file;
return ob_get_clean();
}
public static function make(string $view, array $data = [], ?string $layout = null): string
{
$content = self::buffer($view, $data);
if ($layout) {
return self::buffer($layout, array_merge($data, ['content' => $content]));
}
return $content;
}
}