PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have a bit of a problem...or question, please help if you can...
Basically lets say you create a class that in its constructor creates a DB connection. Now theoretically in other languages you would have to close that connection at some point to prevent hassles. It strikes me that the best place to do this would be in the deconstructor...BUT of course PHP doenst have a deconstructor.
How / What is the best way to do this in PHP? I do need to close that connection correct? Where would you suggest I do that?
I don't think there is overloading of functions. I know you can't overload constructors like in java, so I asume that holds true for all functions. And as for you DB disconnect, just have a disconnect() function that you call when its time to disconnect. I've never really understood deconstructors anyways, having learned OOP in java where the garbage collection is all automatic. I think it has made me sloppy.
The only thing with this is that, it seems to run through it all straight away? Not giving me time to pass the calsee around and use the connection? ie. before I can use it it's closed?