fork download
  1. <?php
  2. class MainController {
  3. public function actionIndex(){
  4. $model = new Model;
  5. if($_SERVER['REQUEST_METHOD'] == 'POST'){
  6. $model->save($_POST['title'], $_POST['article']);
  7. }
  8. $data = $model->getAllArticles();
  9. $this->render($data);
  10. }
  11. private function render($data){
  12. $view = file_get_contents('template.tpl');
  13. $content = '';
  14. while ($row = $data->fetchAll() ) {
  15. $content .= "<h3>{$row['title']}</h3>";
  16. $content .= "<p>{$row['article']}</p>";
  17. }
  18. echo str_replace('{{content}}', $content, $view);
  19. }
  20. }
Success #stdin #stdout 0.02s 24400KB
stdin
Standard input is empty
stdout
Standard output is empty