From d5971b39cb8da8828e093369eec6bfe97d63e0fb Mon Sep 17 00:00:00 2001 From: Raghav <raghavsmart1213@gmail.com> Date: Wed, 5 Mar 2025 06:38:48 +0000 Subject: [PATCH] Test with Destructor and Constructor --- _includes/Mic.class.php | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/_includes/Mic.class.php b/_includes/Mic.class.php index 42e49bc..933932a 100644 --- a/_includes/Mic.class.php +++ b/_includes/Mic.class.php @@ -10,7 +10,8 @@ class Mic public $price; // Creating methods.. - public function setLight($light){ + public function setLight($light) + { print($light);//Returns parameter's value // $this keyword is used to specify the variable inside class. @@ -18,36 +19,48 @@ class Mic } // Call and change model name to first word as uppercase - public function setModel($model){ + public function setModel($model) + { // Store $model values to model with $this. - $this -> model = ucwords($model); //ucwords() converts 1st letter string as uppercase. + $this -> model = \ucwords($model); //ucwords() converts 1st letter string as uppercase. return $this-> model; } // To print the $model as output: - public function getModel(){ + public function getModel() + { print($this-> model); } - // To set value to $color with private method - private function setColor($color){ + // To set value to $color with private method + private function setColor($color) + { $this -> color = $color; } - + // To display the value with private method - private function getColor(){ + private function getColor() + { return $this -> color; } // Accessing private method with public method to get value from test.php - public function setColorProxy($color){ + public function setColorProxy($color) + { $this -> setColor($color); } // Getting values from private method -> private propertiy: to display value to test.php - public function getColorProxy(){ + public function getColorProxy() + { return $this -> getColor(); } + + public function __destruct() + { + print("I am from Destructor....!". $this -> brand); + } + } -- GitLab