Static Functions
Static functions hold the last value assigned between calls. In OOP, they are typically protected so code outside the class doesn't change them.
After creating a Dog, I now have 1 pet(s).
After creating a Cat, I now have 2 pet(s).
After creating a Ferret, I now have 3 pet(s).
After tragedy strikes, I now have 2 pet(s).
After creating a Pygmy Marmoset, I now have 3 pet(s).
There is a stack overflow question on the topic of self:: vs this - which has got me curious about the differenes and usage. http://stackoverflow.com/questions/151969/php-self-vs-this
Hello, I'm louie the Person
(calls public function sayHello in Person class. This function calls the getTitle method using $this->getTitle() - which returns $this->getName and appends text the Person)
Goodbye from louie the Person
(Calls goodbye method of Person class - which uses the self:: scope to get method title which, while in Person class gets the title )
Hello, I'm pointy the geek
(calls public function sayHello in Geek class. This function calls the overrideen getTitle method which concatenates the the parents getName method with the geek
Goodbye from pointy the Person
(Calls goodbye method in Person (no override in Geek class) - which uses the self:: scope to get method title which, while in Person class gets the title )
person counter: 2object(Geek)#8 (1) { ["name":protected]=> string(6) "pointy" } int(2)