File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -517,7 +517,7 @@ $router->get('/profile', function (View $view) {
517517
518518$router->get('/blog/post', function (View $view) {
519519 // It looks for a view with path: __DIR__/../views/blog/post.phtml
520- return $view->make('blog.post', ['user ' => 'Jack' ]);
520+ return $view->make('blog.post', ['post ' => $post ]);
521521});
522522
523523$router->dispatch();
@@ -527,6 +527,19 @@ There is also some points:
527527* View files must have the ".phtml" extension (e.g. ` profile.phtml ` ).
528528* You must separate sub-directories with ` . ` (e.g. ` blog.post ` for ` blog/post.phtml ` ).
529529
530+ View files are pure PHP or mixed with HTML.
531+ You should use PHP language with template style in the view files.
532+ This is a sample view file:
533+
534+ ``` php
535+ <h1 ><?php echo $title ?></h1 >
536+ <ul >
537+ <?php foreach ($posts as $post): ?>
538+ <li ><?php echo $post['content'] ?></li >
539+ <?php endforeach ?>
540+ </ul >
541+ ```
542+
530543### Route Names
531544
532545You can assign names to your routes and use them in your codes instead of the hard-coded URLs.
You can’t perform that action at this time.
0 commit comments