In the controller (which is a class called MessageController), there is this code, which renders a “view” file named helloWorld and also sets an array where the variable $theTime is connected to the key ‘time’.
$theTime = date("D M j G:i:s T Y");
$this->render('helloWorld',array('time'=>$theTime));
In the view helloWorld file, the key ‘time’ from the controller is displayed here through the variable $time
<h3><?php echo $time; ?></h3>
this works perfectly. However, the book also suggests trying another way. It says
Alter the previous example by defining
a public class property on
MessageController, rather than a
locally scoped variable, whose value
is the current date and time. Then
display the time in the view file by
accessing this class property through
$this.
I haven’t been able to figure out how to do this. Anyone know how
in the view: