View Single Post
Old 08-19-2008, 06:23 PM   #2 (permalink)
adamsargant
The Wanderer
 
adamsargant's Avatar
 
Join Date: Aug 2008
Location: Haworth, West Yorkshire
Posts: 5
Thanks: 2
adamsargant is on a distinguished road
Default

"$this" is a pseudo variable used within a class to refer to the class itself. Obviously, since the object hasn't been instantiated yet, we can't use it within the class.

say I have an object $foo

$foo=new myclass();

and a property $bar, I can now call that property

$foo->bar

BUT, within the class code, I don't know I'm going to call the object "$foo", so "$this" is used as a generic reference to the object

I'm just getting my head round classes myself, so I hope that helps

Adam
adamsargant is offline  
Reply With Quote