<?php
class MyDestructableClass {
function __construct() {
print "In constructor<br />";
$this->name = 'MyDestructableClass';
}
function __destruct() {
try
{
$error = 'Always throw this error';
throw new Exception($error);
print 'Destroying ' . $this->name . "<br />";
}
catch (Exception $e)
{
echo 'Caught exception: ', $e->getMessage(), "\n";
}
}
} // end class
$obj = new MyDestructableClass();
?>
Title:
Example of destructor
Description:
<?php class MyDestructableClass { function __construct() { print "In constructor<br />"; $this->name = 'MyDe...
...
Rating:
4