|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
some simple questionsHi,
Does anyone read the Cal Evans book, php|a's Guide to Programming with Zend Framework? I have some simple questions just want to make clear: If a class has a protected member/property, say _data, which be assigned to as a Zend' Db row object on the member table, can you access it as: after $this->_data = $member; $this->emailAddress, instead of $this->_data->emailAddress ? If you read the book, check out the chapter4's sample code, suddenly, we can directly access the $member->emailAdress? And, also, in the register view, when we assigned the view variable emailAddress etc, so use the echo $this->escape($this->emailAddress) do not generate an undefined variable warning? These may stupid simple question, but these kind thing I never do. I check the code, does somewhere in the ZF has utilized the magic method, such as __get or __set to automatically handle this? Thanks. |
|
|
Re: some simple questionsIt doesn't work that way automatically. You have to implement a __get() method in the current class, something like this: public function __get($key) { return $this->_data->$key; } It looks like Zend_View_Abstract has a method strictVars(). By default, Zend_View will return null if you specify a variable that hasn't been defined. If you call $view->strictVars(true), then subsequent references to undefined variables raise an E_USER_NOTICE error. Regards, Bill Karwin |
|
|
Re: some simple questionsExactly!
Thank you! On Tue, Jul 15, 2008 at 1:48 AM, Bill Karwin <bill@...> wrote:
|
|
|
Re: some simple questionsI haven't read the book, but several of the reviews on Amazon [1] mention errors in the code examples. I would trust your instincts when you run across something in the book that doesn't seem right.
-Matt [1] http://www.amazon.com/review/product/0973862157/ref=cm_cr_dp_all_helpful?_encoding=UTF8&coliid=&showViewpoints=1&colid=&sortBy=bySubmissionDateDescending On Mon, Jul 14, 2008 at 10:04 AM, Neriodavid(Wei Dai) <neriodavid@...> wrote: Hi, |
| Free Forum Powered by Nabble | Forum Help |