I had trouble with classes too, but I think the main reason they are tough
at first is because since there is so much talk about how hard/cool object
oriented programming is, we think things are harder than they are.
Think of an object as a jar. Inside the jar are variables and functions
(refered to as "methods", for reasons that someone made up at some point),
mutch like the standard PHP functions.
The use of a class (which is a blueprint for PHP to use to see how an object
should be made) is to simplify coding and allow for variable and function
grouping.
To bring it all down nice and simple, Classes do nearly nothing that can't
be done without them. But they can make it a whole lot easier to do certain
things, and they allow more extensible and portable code to be made (which
is a good thing, certainly).
If you will need multiple instances of the same variables or functions, use
a Class. For instance if you need to have many things with the $color
variable, you could either put it in an associative array or stick it inside
it's own object.
It doesn't allow you to do anything you couldn't already, but it can really
make your life a whole lot simpler in many instances.
The key is to that procedural programming and object oriented programming
are not mutually exclusive. You can use a little of both. And if you are
going to use PHP, you should use both.
PHP isn't Java; it's not an OO language.
PHP isn't...um...FORTAN; it's not a purely PP language.
The world if formed from the void,
like utensils from a block of wood.
The Master knows the utensils,
yet keeps to the block:
thus he can use all things.
--
Plutarck
Should be working on something...
...but forgot what it was.
""SED"" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi,
>
> I have now been 3-4 months writing PHP-codes and read the PHP manual
> throughout. But there is one thing I can't figure out properly (I think
it's
> not covered enough in the manual): Classes!
>
> When and why would I use it?
>
> Is it only to group certain functions or does it have a special function?
>
> Thanks!
>
> Regards,
> Sumarlidi Einar Dadason
>
> SED - Graphic Design
>
> ------------------------------------------
> Phone: (+354) 4615501
> Mobile: (+354) 8960376
> Fax: (+354) 4615503
> E-mail: [EMAIL PROTECTED]
> Homepage: www.sed.is <- New Homepage!
> ------------------------------------------
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]