01-23-2008, 09:58 AM
|
#7 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
|
Quote:
Originally Posted by Tanax
$this can only be used within the class though, and never outside.
Also, there are static variables and functions, and to refer to them you must use the self:: method.
PHP Code:
class staticClass {
public static $szVariable;
public static function setVar($szVar) {
self::$szVariable = $szVar;
}
}
The good thing about this is that you don't have to create the object.
PHP Code:
include('staticClass.php');
staticClass::setVar('Hi there!');
echo staticClass::$szVariable;
Output:
I use this method in my DB factory, and it's awesome!
|
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
__________________
VillageIdiot can have my babbies ;d
|
|
|
|