Hello,
I have been using PHP now for about 6 months doing basic dynamic web page stuff using a mysql database.
On the side I am learning C++ and OOP. Because of this I thought I would attempt to make classes in PHP and further advance my knowledge of OOP.
Right now I am trying to think of things that should be placed in a class for reusability. The first thing that comes to mind would be to make a "Utility" class. This class would perform basic things like connect to a database, store header and footer information, etc...
I am just curious if this is a good idea for how to use classes in PHP. This way I could simply include the class in my source and just call classVar.Connect() or classVar.Header(), etc...
The other thing I wanted to use classes for is session tracking. On my web sites I have a login script which then stores, username, first name, etc... in a session variable. I know this probably isn't the wisest method, but it does the trick right now.
Because this isn't the best method I was thinking of doing a class approach. My idea would be as follows. In my class rather than using session variables I would use class variables in the private section and provide get/set routines for these variables.
My only question to this approach is how would the variables maintain state across several pages?
If anyone has some experience or wants to pass on some experience to me I would like to hear it. Or if you know of any existing articles or tutorials on this concept that would also be useful.
Thanks.