-- Dan Field [EMAIL PROTECTED] wrote
(on Wednesday, 01 August 2007, 09:25 AM +0100):
I'm sure I read somewhere, that we should not create member variables
in the controllers. Is this right? Is there an alternative? or have I
got the wrong end of the stick somehow? Now I think about it, it
might have been due to coding standards and the use of the var
identifier? why is this wrong?
Of course you can create member variables in the controllers. It's just
that in PHP 5, you should use a visibility keyword (public, private,
protected) instead of 'var' when declaring them:
class IndexController extends Zend_Controller_Action
{
/**
* Model object
* @var IndexModel
*/
public $model;
}
Additionally, PHP's object model lets you create new member variables on
the fly, and these are automatically public:
$this-foo = 'bar'; // implicitly creates 'foo' member w/public visibility
--
Matthew Weier O'Phinney
PHP Developer| [EMAIL PROTECTED]
Zend - The PHP Company | http://www.zend.com/