01-23-2008, 09:53 AM
|
#6 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
$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!
|
|
|
|