Re: where are the good examples of using OOP?

From: Date: Sun, 28 Sep 2003 11:41:25 +0000
Subject: Re: where are the good examples of using OOP?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-164165@lists.php.net to get a copy of this message
On Sun, Sep 28, 2003 at 12:52:40PM +0200, anders thoresson wrote: : : I wonder if someone can point me to tutorials that uses real PHP examples : instead, examples that shows me in a direct way how to use OOP. My biggest : trouble right now is what should be the classes and what should be the : methods. Objects should try to model a real thing. A thing may have properties (e.g. weight, color, dimensions, temperature, gender, age) and/or states (e.g. solid/liquid/gas, running/ready/waiting, eating/sleeping/working); properties are stored in instance variables. And the thing can do tasks or have tasks done to them; these tasks are your methods. Here's a simple exercise you can do: make a "watch" class that models a real watch. You can get the current time from a watch; and you can also set the watch's time. This class should have 3 methods (i.e. 2 methods and 1 constructor) and 1 instance variable. If you use Unix timestamps, this should be really short (maybe around 10 lines of PHP code).

« previous php.general (#164165) next »