<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://wbex.ru/index.php?action=history&amp;feed=atom&amp;title=PHP%2FClass%2FDestructors</id>
		<title>PHP/Class/Destructors - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://wbex.ru/index.php?action=history&amp;feed=atom&amp;title=PHP%2FClass%2FDestructors"/>
		<link rel="alternate" type="text/html" href="http://wbex.ru/index.php?title=PHP/Class/Destructors&amp;action=history"/>
		<updated>2026-04-05T04:22:42Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://wbex.ru/index.php?title=PHP/Class/Destructors&amp;diff=36&amp;oldid=prev</id>
		<title> в 10:37, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://wbex.ru/index.php?title=PHP/Class/Destructors&amp;diff=36&amp;oldid=prev"/>
				<updated>2010-05-26T10:37:27Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 10:37, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://wbex.ru/index.php?title=PHP/Class/Destructors&amp;diff=37&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://wbex.ru/index.php?title=PHP/Class/Destructors&amp;diff=37&amp;oldid=prev"/>
				<updated>2010-05-26T07:00:44Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Accessing instance-specific data within a destructor==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
class Database {&lt;br /&gt;
    function __destruct() {&lt;br /&gt;
         db_close($this-&amp;gt;handle); &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Class destructors==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
   class Book&lt;br /&gt;
   {&lt;br /&gt;
      private $title;&lt;br /&gt;
      private $isbn;&lt;br /&gt;
      private $copies;&lt;br /&gt;
      function __construct($isbn)&lt;br /&gt;
      {&lt;br /&gt;
         echo &amp;quot;&amp;lt;p&amp;gt;Book class instance created.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
      }&lt;br /&gt;
      function __destruct()&lt;br /&gt;
      {&lt;br /&gt;
         echo &amp;quot;&amp;lt;p&amp;gt;Book class instance destroyed.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
   $book = new Book(&amp;quot;1111&amp;quot;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Class with destructors==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
    class Book&lt;br /&gt;
    {&lt;br /&gt;
        private $title;&lt;br /&gt;
        private $isbn;&lt;br /&gt;
        private $copies;&lt;br /&gt;
        function __construct($isbn)&lt;br /&gt;
        {&lt;br /&gt;
            echo &amp;quot;&amp;lt;p&amp;gt;Book class instance created.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
        function __destruct()&lt;br /&gt;
        {&lt;br /&gt;
            echo &amp;quot;&amp;lt;p&amp;gt;Book class instance destroyed.&amp;lt;/p&amp;gt;&amp;quot;;&lt;br /&gt;
        }  &lt;br /&gt;
    }&lt;br /&gt;
    $book = new Book(&amp;quot;111111111111&amp;quot;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Cleaning Up with the __destruct Method (PHP 5 Only)==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
class ItemUpdater {&lt;br /&gt;
  public function update( Item $item ) {&lt;br /&gt;
    print &amp;quot;updating.. &amp;quot;;&lt;br /&gt;
    print $item-&amp;gt;name;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class Item {&lt;br /&gt;
  public $name = &amp;quot;item&amp;quot;;&lt;br /&gt;
  private $updater;&lt;br /&gt;
  public function setUpdater( ItemUpdater $update ) {&lt;br /&gt;
    $this-&amp;gt;updater=$update;&lt;br /&gt;
  }&lt;br /&gt;
  function __destruct() {&lt;br /&gt;
    if ( ! empty( $this-&amp;gt;updater )) {&lt;br /&gt;
      $this-&amp;gt;updater-&amp;gt;update( $this );&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
$item = new Item();&lt;br /&gt;
$item-&amp;gt;setUpdater( new ItemUpdater() ) ;&lt;br /&gt;
unset( $item );&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Declaring and Using Object Constructors and Destructors==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
class cd {&lt;br /&gt;
    public $artist;&lt;br /&gt;
    public $title;&lt;br /&gt;
    protected $tracks;&lt;br /&gt;
    private $disk_id;&lt;br /&gt;
    public function __construct() {&lt;br /&gt;
        $this-&amp;gt;disk_id = sha1(&amp;quot;cd&amp;quot; . time() . rand());&lt;br /&gt;
    }&lt;br /&gt;
    public function get_disk_id() {&lt;br /&gt;
        return $this-&amp;gt;disk_id;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
$mydisk = new cd();&lt;br /&gt;
echo $mydisk-&amp;gt;get_disk_id();&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Defining an object destructor==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
class car {&lt;br /&gt;
    function __destruct() {&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==destuctor in action==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
class Person {&lt;br /&gt;
    protected $name;    &lt;br /&gt;
    private $age;    &lt;br /&gt;
    private $id;    &lt;br /&gt;
    function __construct( $name, $age ) {&lt;br /&gt;
        $this-&amp;gt;name = $name;&lt;br /&gt;
        $this-&amp;gt;age  = $age;&lt;br /&gt;
    }&lt;br /&gt;
    function setId( $id ) {&lt;br /&gt;
        $this-&amp;gt;id = $id;&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    function __destruct() {&lt;br /&gt;
        if ( ! empty( $this-&amp;gt;id ) ) {&lt;br /&gt;
            print &amp;quot;saving person\n&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
$person = new Person( &amp;quot;Joe&amp;quot;, 31 );&lt;br /&gt;
$person-&amp;gt;setId( 111 );&lt;br /&gt;
unset( $person );&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>