Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php ## Базовый класс страницы
- class Page
- {
- // Любая страница имеет заголовок
- protected $title;
- // И содержимое
- protected $content;
- // Конструктор класса
- public function __construct($title = '', $content = '')
- {
- $this->title = $title;
- $this->content = $content;
- }
- // Получение заголовка страницы
- public function title()
- {
- return $this->title;
- }
- // Получение содержимого страницы
- public function content()
- {
- return $this->content;
- }
- // Формирование HTML-представления страницы
- public function render()
- {
- echo "<h1>".htmlspecialchars($this->title())."</h1>";
- echo "</p>".nl2br(htmlspecialchars($this->content()))."</p>";
- }
- }
- $aa = new Page("Hello world!");
- $aa->render();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment