Confused About Classes

From: Date: Mon, 25 Mar 2002 14:59:12 +0000
Subject: Confused About Classes
Groups: php.dev 
Request: Send a blank email to php-dev+get-81776@lists.php.net to get a copy of this message
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; } 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. Thanks, -- Brian

« previous php.dev (#81776) next »