View include ob_start()

dakata__92

Super Moderator
Клеги драскам си View class и искам да попитам защо се ползва обстарт и най-вече защо когато ползвам при инклудването ob_get_clean(); Не ми си визуализират нещата ?
PHP:
public function includeFile($path){
		if (file_exists($path) && is_readable($path)) {
            ob_start();
            include $path; 
			ob_get_clean();
        }else{
            throw new \Exception('View ' . $path . ' cannot be included', 500);
        }
	}

Ако ползвам само ob_start(); include $path; се визуализират. Как бихте постъпили вие при визуализацията и другите рамки се справят с този проблем?
 
Ок но нещо май не правя при визуализирането на html-а... Как да построя самият шаблон?
PHP:
public function display($data = array()){
		$this->data = $data;
		$template = $this->includeFile($this->options['FilePath']);
		print_r($template);
	}
	
	public function includeFile($path){
		if(file_exists($path) && is_readable($path)) {
            ob_start();
            include $path; 
			return ob_get_clean();
        }else{
            throw new \Exception('View path cannot be included.', 500);
        }
	}
Това са двата важни метода, и ето така като направя нещата се показват. Въпроса ми е има ли по-оптимизиран варянт?
HTML:
<html>
<head>
<meta charset="UTF-8"/>
<title><?php print $this->data['title']; ?></title>
</head>
<body>
Hellow View Page<br>
<?php print $this->data['post']; ?>

<br>ab -n 1000 -c 5	http://localhost/dph/ccf/public/


</body>
</html>
 

Back
Горе