Thread: uhh... OOP?
View Single Post
Old 01-23-2008, 10:10 AM   #9 (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
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, this 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..
Thanks for clearly that up for me, I've only been doing PHP for about 8 months to a year now so..

Off Topic:
GTalk notification of a new Email on the GMail email system has a long delay, lol.

By the way, you could just use the __autoload() magic method for grabbing php classes, :) though it doesnt work in the CLI
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote