Untitled

Run Settings
LanguagePHP
Language Version
Run Command
<?php require __DIR__ . '/Article.php'; require __DIR__ . '/News.php'; require __DIR__ . '/View.php'; $Article1 = new Article('заголовок1','Описание1','Полный текст1'); $Article2 = new Article('заголовок2 ','описание2','Полный текст2'); $news = new News; $news->upload($Article1); $news->upload($Article2); $view = new View(); $view->assign('news', $news->getNews()); echo $view->render('news');
<html> <head> <title> Все Новости </title> </head> <body> <?php foreach ($news as $acticle) : ?> <article> <h2><?= $acticle->header; ?></h2> <p><?= $acticle->shorttext; ?></p> </article> <?php endforeach; ?> </body> </html>
<?php class News { public $newsarray = []; public function getNews() { return $this->newsarray; } public function upload(Article $article) { $this->newsarray[] = $article; } }
<?php class Article { public $header; public $text; public $shorttext; public function __construct($header,$shorttext, $text) { $this->header = $header; $this->text = $text; $this->shorttext = $shorttext; } }
<?php class View { protected $value1 = []; public function assign($name,$value) { $this->value1[$name] = $value; } public function render($template) { ob_start(); extract($this->value1); include __DIR__ . '/' . $template .'.tpl.php'; $bufdata = ob_get_contents(); ob_end_clean(); return $bufdata; } }
Editor Settings
Theme
Key bindings
Full width
Lines