Class Variable Scope Question

From: Date: Wed, 15 Mar 2006 19:51:44 +0000
Subject: Class Variable Scope Question
Groups: php.general 
Request: Send a blank email to php-general+get-231972@lists.php.net to get a copy of this message
Hi Guys, I am wondering how to be able to call a class variable from within an outside function using the "::" syntax: See an example of the logic I am using below: class myClass { var $variable = 1; function showVar() { return $this->variable; } } $obj = new myClass; function extFunction() { return myClass::showVar(); } I am assuming this isn't working because by calling myClass::showVar() instead of $obj->showVar() "$this" would be undefined...does anyone know how to workaround this (e.g. direct access to a variable via "::" syntax like myClass::variable). Does PHP5 address this at all? Many thanks on this. Best, Mike D ................................................................... Mike Dunlop Director of Technology Development [ e ] miked@m80im.com [ p ] 323.644.7808

« previous php.general (#231972) next »