Thread: uhh... OOP?
View Single Post
Old 01-23-2008, 09:53 AM   #6 (permalink)
Tanax
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

$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!
Tanax is offline  
Reply With Quote