Hi all,
I'd like to bring this topic back up since it's 2011 and I still have the problem of finding real world examples. I have looked with google and I have tons of php ebooks that barely mention this part of OOP. Daniel10's example is much better than the whole dog/cat or car/van and definitely much better than the foo/bar examples. Daniel10's example is real world and can be explained in the same way as the dog/cat examples but it's easier to understand in my opinion.
I think it would be great for all beginners in the PHP community if we accept that there are tons of dog/cat/car/van/foo/bar examples so understanding the concept at a beginner level is not in question any more.
Now truly understanding the concept by seeing how it works in a real world example is what is needed.
For example, I tried to understand extending exceptions at php.net http://php.net/manual/en/language.exceptions.extending.php (example 2). I started asking around on forums and was being advised by many people to make an abstract class because it apparently is bad practice to directly extend a core class. I never did find out why this is bad. But anyway, when I asked about how to do this I kept getting the foo/bar and cat/dog responses which made no sense to me at all in the context of creating an abstract class to extend exception and then how to use that class in a real program. It's silly that some people seemed to go so far out of the way to make sure they didn't write the code for me that their examples were just ridiculous. I don't want someone to write an application for me. But for a few real world examples it would be nice to see complete code and an explanation of it.
That's the kind of example I would love to see with a explanation of why and how it works. Would anyone like to share abstract classes they use in their own applications and a brief tutorial of the why's and how's? I hope you don't actually have a program for tracking cat/dog inventory or monkey's, giraffes, and tigers at your imaginary zoo. :-)
Thank you to anyone who wants share your knowledge and skill so beginners can learn something real.