01-23-2008, 10:07 AM
|
#8 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Quote:
Originally Posted by Orc
Isn't the alternative way of doing that would be
PHP Code:
staticClass->setVar('Hi There!'); staticClass->$szVariable;
Considering I know thats the alternative way. or :s;S;d
|
No, the alternate way would be to instead of having the function and variable static, you just use the normals:
PHP Code:
class staticClass { public $szVariable;
public function setVar($szVar) { $this->szVariable = $szVar; }
}
Also note that you have to use $this instead of self:: when referring to $szVariable inside the class.
But then you have to create the object:
PHP Code:
include('staticClass.php');
$object = new staticClass(); $object->setVar('Hi there!'); echo $object->szVariable;
In this simple example, static method doesn't seem very useful, but I promise that it's a GREAT method when using a DB factory.
If this topic is still going when I get home from school in about 3 hours, I'll post my DB factory, and explain how to use it..
|
|
|
|