Posted by Mike Willbanks on 05/10/05 01:42
Burnsy,
> Generally if I re-use code, I use a function. If I need to use these
> functions over a number of pages I write the function to an include
> file where all pages have access.
>
> So when should I ever use PHP classes instead. I have learned how to
> put together PHP classes but never seen a reason to use them where I
> can simply use a function.
>
> Im basically just wanting to know classes benefits over functions. If
> something can be better put together in a class I would like to be
> doing it that way. Any suggestions?
Normally I code a massive amount of objects and simple functions and
arrays of configuration.
What I normally do is put all of my business logic into classes that
have actions. Then as the last poster noted that you can always extend
those operations which makes it extremely scalable.
Most things that I use for objects are authentication and also database.
This helps when I transfer to different DBs (have had to do it a
couple times, not pretty when things are just coded to one specific item).
Another nice thing about objects is it gives you a chance to group all
of your functions and have variables that can be global to all the
functions but not global within the scripts. That can help massively on
many cases. (template systems are huge examples of this type of
importance).
I'm sure there will be more stuff posted later but as stated before it
is a all about your opinion.
Mike
Navigation:
[Reply to this message]
|