Re: Confused About Classes
| From: | Markus Fischer | Date: | Mon, 25 Mar 2002 15:23:44 +0000 |
| Subject: | Re: Confused About Classes | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-81783@lists.php.net to get a copy of this message | ||
On Mon, Mar 25, 2002 at 09:59:12AM -0500, arti wrote :
> I do not understand why I am getting the error "Undefined variable this" in
> this snippet of code (note for brevity I cut out a lot of code):
>
> <?php
> class standardquestion
> {
> var $private;
>
> function standardquestion($xmlfilename)
> {
>
> $this->private=FALSE;
>
> <skip some stuff here>
>
> }
>
> function startElementHandler($parser, $name, $attribs)
> {
> if ($name=="private")
> $this->private = TRUE;
>
> if ($this->private==FALSE) // <<<<---- Undefined variable
> this
> return;
> }
You're missing the relevant which calls this method.
> As you can see, I initialize the variable as the first line in the
> constructor. But, why is "this" suddenly undefined? I presume I'm doing
> something stupid, but I am new to PHP and am missing something here.
For the future, such things should be targeted at
php-general@lists.php.net ; NOT php-dev@
--
Please always Cc to me when replying to me on the lists.
GnuPG Key: http://guru.josefine.at/~mfischer/C2272BD0.asc