Thread: uhh... OOP?
View Single Post
Old 01-23-2008, 09:58 AM   #7 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
$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:
Code:
Hi there!
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
Orc is offline  
Reply With Quote