__destruct() function example

<?php

/*A __destruct() function is a special function that is executed each time an object of a class destroy …

Its may usefull for unsetting variables or disconnect the database connection … */

class api
{
public $a;

function __construct($n)
{
$this->a = $n;
echo $this->a;

}
function __destruct()
{
echo “<br/>The Object’s property “.$this->a.” is destroyed..”;
}
}

$object = new api(‘Hello’);

?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s