Home | Mirror | Search

第 18 章 PHP Classes 類與對象

目錄

1. 建構子和解構子 __construct() / __destruct()
2. Traits

1. 建構子和解構子 __construct() / __destruct()

		
<?php
class MyClass {
   function __construct() {
       print "In constructor\n";
       $this->name = "MyClass";
   }

   function __destruct() {
       print "Destroying " . $this->name . "\n";
   }
}

$obj = new MyClass();
?>
		

		
comments powered by Disqus