-
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);
}
}
>
-
Re: Destructor in PHP5
The destructor in php to my knowledge has no value.
-
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
-
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)
Page generated in 1,714,078,575.63495 seconds with 11 queries