Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Destructor in PHP5

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 17-03-2009
Member
 
Join Date: Nov 2008
Posts: 159
Destructor in PHP5
  

A small question about the destructor (__destruct ()) of a class in PHP5.

Is it required to remove the attributes of the class in the destructor or does the mere fact that the object is destroyed, or unset () or at the end of the script enough to release, to. Similarly, data stored in its properties when executing the destructor?

Are we obliged to do this:

Code:
<?php 
class MyObject
{
private $myVar; 
public function __construct() { }
public function doIt() { }
public function __destruct () 
{
/ / Code or compulsory destruction of properties of the object made by implication? 
unset($ this ->myVar);
}
}
>

Reply With Quote
  #2  
Old 18-03-2009
XSI XSI is offline
Member
 
Join Date: May 2008
Posts: 271
Re: Destructor in PHP5

The destructor in php to my knowledge has no value.
Reply With Quote
  #3  
Old 18-03-2009
Member
 
Join Date: May 2008
Posts: 685
Re: Destructor in PHP5

I read in a book that was good for "close" files/sql connections. Except that I have ever own resources to a class. So, yes, I do not use to destruct
Reply With Quote
  #4  
Old 18-03-2009
Member
 
Join Date: May 2008
Posts: 945
Re: Destructor in PHP5

Close the resources that are potentially useless (I do not know if PHP automatically closes all files at the end of a script for example, or all SQL connections)
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Destructor in PHP5"
Thread Thread Starter Forum Replies Last Post
Problem in LinkedList destructor. KAIRU26 Software Development 5 15-02-2010 06:14 PM
What is the difference between a destructor and a finalizer? Taylor D Software Development 5 27-01-2010 09:47 AM
Basic use of destructor Sacchidananda Software Development 3 19-11-2009 09:20 AM
Abstract Classes in PHP5 nonose Software Development 2 16-06-2009 02:33 PM
Destructor in Java Anti_Trend Software Development 7 25-10-2008 03:27 PM


All times are GMT +5.5. The time now is 03:09 PM.