Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
short_open_tag
PHP_INI_PERDIR
PHP_INI_ALL in PHP <= 4.0.0.
PHP_INI_PERDIR 2 Entry can be set in php.ini, .htaccess or httpd.conf
«Магический» метод __get возвращает значение переданной в шаблон переменной. Если переменная не определена, возвращает false. В зависимости от параметров, переменные перед отдачей могут обрабатываться.
fucntion __get($k){
if (isset($this->vars[$k]))
return $this->vars[$k];
return null;
}
<?php if (!$this->user) { ?><a href="/authorization">Авторизуйтесь</a><?php } ?><?php if ($this->user == "undefined") { ?><a href="/authorization">Авторизуйтесь</a><?php } ?><?php
// Load the Savant3 class file and create an instance.
require_once 'Savant3.php';
$tpl = new Savant3();
// Create a title.
$name = «Some Of My Favorite Books»;
// Generate an array of book authors and titles.
$booklist = array(
array(
'author' => 'Hernando de Soto',
'title' => 'The Mystery of Capitalism'
),
array(
'author' => 'Neal Stephenson',
'title' => 'Cryptonomicon'
),
array(
'author' => 'Milton Friedman',
'title' => 'Free to Choose'
)
);
// Assign values to the Savant instance.
$tpl->title = $name;
$tpl->books = $booklist;
// Display a template using the assigned values.
$tpl->display('books.tpl.php');
?>
<html>
<head>
<title><?php echo $this->eprint($this->title); ?></title>
</head>
<body>
<?php if (is_array($this->books)): ?>
<!-- A table of some books. -->
<table>
<tr>
<th>Author</th>
<th>Title</th>
</tr>
<?php foreach ($this->books as $key => $val): ?>
<tr>
<td><?php echo $this->eprint($val['author']); ?></td>
<td><?php echo $this->eprint($val['title']); ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php else: ?>
<p>There are no books to display.</p>
<?php endif; ?>
</body>
</html>
Нативный шаблонизатор