xing93111 wrote:
>
> Hi,
>
> I try to define class variables in a controller class. For example:
>
> class ForumController extends Zend_Controller_Action
> {
> protected $_forumid;
>
> public function indexAction() {
> ...
> $_forumid = $somevalue;
> }
> ...
>
> }
>
> However, it seems does not work. I cannot use $_forumid in other functions
> in the same controller class. Any one can help
>
> Thank you very much
>
> Bill
>
Couple of things going on here:
1) to set a class var you need to use the $this-> syntax, i.e.
$this->_forumid = $somevalue;
2) in other action calls the indexAction() function does not run. You need
to do your class initializations in the init() function, i.e.
public function init()
{
$this->_forumid = 'somevalue';
}
The init function is called automatically in the controller constructor.
--
View this message in context:
http://www.nabble.com/Can-controller-class-have-class-variables--tp16723533p16727269.html
Sent from the Zend Framework mailing list archive at Nabble.com.