RE: [PHP] Class Variable Scope Question

From: Date: Wed, 15 Mar 2006 20:01:04 +0000
Subject: RE: [PHP] Class Variable Scope Question
Groups: php.general 
Request: Send a blank email to php-general+get-231973@lists.php.net to get a copy of this message
[snip] 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? [/snip] http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php

« previous php.general (#231973) next »