Section 8.5. The this Variable


8.5. 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. For example:

     function bark( ) {             print "{$this->Name} says Woof!\n";     } 

When calling an object method, PHP automatically sets the $this variable that contains that objectyou do not need to do anything to have access to it.



PHP in a Nutshell
Ubuntu Unleashed
ISBN: 596100671
EAN: 2147483647
Year: 2003
Pages: 249

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net