name.",價錢是".$this->price.",顏色是".$this->color; } } $a1 = new phone(); $a1->name = "iphone 12"; $a1->price = 25000; $a1->color = "red"; echo $a1->name; echo "
"; $a1->show(); echo "

"; //2.第二個物件類別 stu class stu { public $name; public $sex; public $tel; public function __construct($c1,$c2,$c3) { $this->name = $c1; $this->sex = $c2; $this->tel = $c3; } public function __destruct() { $this->name = NULL; $this->sex = NULL; $this->tel = NULL; echo "
hi...我正在釋放類別變數的記憶體空間"; } public function show() { echo "你的姓名是".$this->name.",電話是".$this->tel.",性別是".$this->sex; } } $a2 = new stu("john","boy","0912456789"); echo $a2->name; $a2->show(); echo "

"; $a2 = NULL; ?>