| 1234567891011121314151617181920212223 |
- <?php
- class View {
- protected static $included = [];
- public static function include($view, $params = []) {
- $view_path = ROOT_DIR . "/views/" . $view . ".php";
- if(file_exists($view_path)) {
- self::$included[] = $view;
- extract($params);
- require $view_path;
- }
- else {
- throw new Exception("View \"$view\" not found");
- }
- }
- public static function includeOnce($view, $params = []) {
- if(in_array($view, self::$included)) return;
- self::include($view, $params);
- }
- }
|