Hello
Its not very clear to me, if we have defined a class, and while in the program which we have written, we declare several object from that class, is there any need for us to call a destructor wheneve our job is done with that object and is no longer needed!
I mean what happens if we dont define any destructor method? will it consume memory?
I would be thankful if someone can explain this to me....
Thanks in advance
PHP class constructor & destructor
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: PHP class constructor & destructor
A destructor is rarely needed.... it's mostly for cleaning up in a large object. I wouldn't worry about it, you'll know when you need to use one (if ever). The memory consumed isn't really even worth taking about... PHP handles memory quite well without having to make too many considerations during development unlike languages like C.Mohammad wrote:Hello
Its not very clear to me, if we have defined a class, and while in the program which we have written, we declare several object from that class, is there any need for us to call a destructor wheneve our job is done with that object and is no longer needed!
I mean what happens if we dont define any destructor method? will it consume memory?
I would be thankful if someone can explain this to me....
Thanks in advance