Class Variable Scope Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx
[ p ] 323.644.7808



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux