السلام هليكم ورحمة الله وبركاته
عندما نقوم بستخدام __destruct() فهل هذا يعني اننا قمنا بتديمر التصنيف وبالتالي سوف تتدمر المتغيرات التي بداخل التصنيف ولن نستطيع استخدامها في تصنيف اخر حتى لو كان وريث للتصنيف المدر ؟
مثال بدون مدمر التصنيف __destruct() ومالذي سيحدث لو قمنا بستخدام مدمر التصنيف
التصنيف الاساسي والذي اريد ان ا اطبق عليه مدمر التصنيف
class add
{
protected $x;//Attribute
protected $y;//Attribute
//methods
protected function getadd()
{
$culc = $this->x + $this->y;
return $culc;
}
function __construct()//Constructor
{
$this->x = 6;
$this->y = 6;
}
function __destruct()
{
}
}التصنيف الوريث الزي سيتأثر بمدر التصنيف الموجود في التصنيف الرئيسي
class subadd extends add
{
protected $z;//Attribute
//methods
protected function getsubadd_method()
{
$culc = $this->x + $this->y + $this->z;
return $culc;
}
function __construct()//Constructor
{
parent::__construct();
$this->z = 1;
echo $this->getsubadd_method();
}
}
//Start calss
$x = new subadd();