so far the syntax is not the problem but my question is more about better understanding OOP
I am creating a class called “user” which should describe a user. typically such class would set user variables and retrieve them
would that class have a method for signingup a new user as well?
how about login?
if not ..how would I structure it?
should “signing up” be another class? in which case wouldn’t the resulting object be a “user”
same goes for the a login class…
sorry for the novis question….just trying to wrap my head around OOP.
thanks for the help 🙂
Most PHP OOP applications would use a model-view-controller (MVC) approach to solve this, with your user class being the ‘model’ and a ‘controller’ class providing business logic that interacts with your user class, like ‘signup’ or ‘login’. The ‘view’ part refers to the presentation code (a mix of PHP / HTML) that gets output to the browser.
A controller approach would look something like this:
This is just a really basic example, but generally you don’t want to mix your application logic (actions such as login or signup) with your domain logic (which should just concern managing your data).
A good article on MVC in PHP can be found here: http://oreilly.com/php/archive/mvc-intro.html