Difficulties in modifying registering object
Hi,
I created a class "Page" , save it in the lib folder.
<?php
class Page{
var $name = null;
}
I load it into my bootstrap file-index.php, then create an object
$myPage = new Page();
$myPage->name = "BOOTSTRAP";
then I registered it:
Zend::register('myPage',$myPage);
In my indexAction controller, I access the object:
function indexAction(){
$myPage = Zend::registry('myPage');
$myPage->name = "INDEX ACTION";
echo $myPage->name;
}
and in my listAction controller, I access the same object:
function listAction(){
$myPage = Zend::registry('myPage');
echo $myPage->name;
}
Now, when I run the page, First page I got message "INDEX ACTION", good.
But, when I open Index/List , I got message "BOOTSTRAP"... I was expecting to get a message "INDEX ACTION"..
So, it seems that when I execute Index/List, myPage object is re-created again in the bootstrap file, so the value back to the first.
My question is, how can I make myPage not be re-created when I execute Index/List ?
Thanks!
|