niko42
Новичок
Здравствуйте.
Класс представления данных:
Есть основной шаблон template
Подключаем доп. шаблон
Теперь хочу обратиться к перменной $product в test.php и вывести на экран информацию
Уточните, пожалуйста, почему test.php не видет переменную $product
Класс представления данных:
PHP:
class View {
static $instance;
static function instance(){
if(!isset($instance)){
return new View();
}
return self::$instance;
}
function generate($content_view = null, $template_view = null)
{
if($template_view == null)
$template_view = "template_view.php";
include 'application/view/'.$template_view;
}
static function set($view){
$dirs = array('application/view/', 'application/tpl/');
foreach($dirs as $dir){
if(file_exists($dir.$view)){
include $dir.$view;
}
}
}
static function start(){
ob_start();
}
static function end(){
echo ob_get_clean();
}
}
PHP:
<html>
<head></head>
<body>
<? View::set($content_view); ?>
</body>
</html>
PHP:
$product = new Product();
$product = $s->getProduct();
View::start();
View::set("test.php");
View::set("test2.php");
View::end();
PHP:
<h1>
echo $product
</h1>