Hi All
I'm pretty new to PHP. I've done some relatively complicated bits now:
written my own little shopping cart, written a content management system
with file uploads, built in newsletters, etc, etc.
The problem is, my code is probably not very elegant. For example, in my
CMS I have a page for adding pages and a page for editing pages. Much of
the code is repeated in the two pages.
So, what I'm having difficulty with is what's the difference bewteen a class
and a function? A function to me looks like a piece of code in an external
file (possibly) that I can call when I need it instead of duplicating code
in different files. A class looks to achieve the same thing. Am I missing
the point somewhere?
Cheers
Andy
I'm pretty new to PHP. I've done some relatively complicated bits now:
written my own little shopping cart, written a content management system
with file uploads, built in newsletters, etc, etc.
The problem is, my code is probably not very elegant. For example, in my
CMS I have a page for adding pages and a page for editing pages. Much of
the code is repeated in the two pages.
So, what I'm having difficulty with is what's the difference bewteen a class
and a function? A function to me looks like a piece of code in an external
file (possibly) that I can call when I need it instead of duplicating code
in different files. A class looks to achieve the same thing. Am I missing
the point somewhere?
Cheers
Andy
Comment