October 2005
Intermediate to advanced
372 pages
11h 35m
English
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. For example:
function bark() {
print "{$this->Name} says Woof!\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.