View Single Post
Old 05-13-2009, 04:01 PM   #1 (permalink)
allworknoplay
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default The "$this->" variable...

Ok so I've been reading a million books to fully understand how $this-> works and I think I've got it. I'll try to explain, I hope I get it right, for the sake of brevity, we have a simple class here:

PHP Code:
class myClass {

public 
$variable1;

public function 
method() {

}

}
// END CLASS 

When the main script instantiates this class and creates the object:

$myClass = new myClass();


Well, $myClass-> and $this-> are basically the same thing. You can access methods/properties the same way.

The only difference is that if a property/method is set to private, then the outside object will have no direct access, but the inside object "$this->" will have access....

And that's pretty much it? Did I get it right?

Someone? Anyone??

Are there any other differences between the two that I missed?
allworknoplay is offline  
Reply With Quote