Jump to content

Destroying PHP object


thangappan

Recommended Posts

I want to destroy an object with in a class.

class Add{

          var $name;

          function add_name($name){

          $this->name =$name;

          }

}

 

$object = new Add();

echo $object->add_name('Testing');

echo Add::name;

 

It prints Testing.

For an example, I am creating more than object dynamically.I want to destroy when the use of object has been finished.

 

For a single class we can use unset() function to destroy an object.For more than one class what is the correct way? Can any one explain?

 

I want to destroy an object with in a class.

class Add{

           var $name;

           function add_name($name){

           $this->name =$name;

           }

}

 

$object = new Add();

echo $object->add_name('Testing');

echo Add::name;

 

It prints Testing.

For an example, I am creating more than object dynamically.I want to destroy when the use of object has been finished.

 

For a single class we can use unset() function to destroy an object.For more than one class what is the correct way? Can any one explain?

 

http://us.php.net/language.oop5.decon

 

Read the section on Destructor's

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.