phpist

Untitled

Oct 27th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. <?php ## Базовый класс страницы
  2. echo '1';
  3. ini_set('display_errors', 1);
  4. echo '2';
  5. error_reporting(E_ALL);
  6. echo '3';
  7. class Page
  8. {
  9. // Любая страница имеет заголовок
  10. protected $title;
  11. // И содержимое
  12. protected $content;
  13. // Конструктор класса
  14. public function __construct($title = '', $content = '')
  15. {
  16. echo '5';
  17. $this->title = $title;
  18. $this->content = $content;
  19. }
  20. // Получение заголовка страницы
  21. public function title()
  22. {
  23. echo '8';
  24. return $this->title;
  25. }
  26. // Получение содержимого страницы
  27. public function content()
  28. {
  29. echo '9';
  30. return $this->content;
  31. }
  32. // Формирование HTML-представления страницы
  33. public function render()
  34. {
  35. echo '7';
  36. echo "<h1>".htmlspecialchars($this->title())."</h1>";
  37. echo "</p>".nl2br(htmlspecialchars($this->content()))."</p>";
  38. }
  39. }
  40. echo '4';
  41.  
  42. $content = "Hello world!";
  43.  
  44. $aa = new Page($content);
  45. ////$title = "Hello world!";
  46. echo '6';
  47. $aa->render();
  48. //$content = "Hello world!";
  49. echo '10';
  50.  
  51. // $aa->content($content);
  52.  
  53. //Page::render();
  54. ?>
  55.  
  56.  
  57. 12345678
  58. Hello world!
  59. 9
  60.  
  61. 10
Advertisement
Add Comment
Please, Sign In to add comment