Adding dynamic content
The simplest way to add dynamic content to our view template is to embed PHP code into the template itself. View files are rendered by our simple application to result in HTML, and any basic text in these files is passed through without being changed. However, any content between the <?php and?> tags is interpreted and executed as PHP code. This is a typical way PHP code is embedded within HTML files and is probably familiar to you.
Adding the date and time
To spice up our page with dynamic content, let's display the date and time. Open up the helloWorld view again and add the following line below the greeting text:
<h3><?php echo date("D M j G:i:s T Y"); ?></h3>Save, and view it at the following URL: http://yourhostname/demo/index.php?r=message/helloWorld
Presto! We have added dynamic content to our application. With each page refresh, we see the displayed content changing.
Admittedly, this is not terribly exciting, but it does show how to embed...