The 'this' Variable
Once inside an object's method, you have complete access to its properties, but to set them you need to be more specific than just using the property name you want to work with. To specify you want to work with a local property, you need to use the special $this variable, which always points to the object you are currently working with.
Ex. : function say( )
{
print "{$this->Name} says Hello!\n";
}
When calling an object method, PHP automatically sets the $this variable that contains that object you do not need to do anything to have access to it.
0 comments:
Post a Comment