Skip to content
Snippets Groups Projects
Commit d5971b39 authored by Raghav's avatar Raghav
Browse files

Test with Destructor and Constructor

parent 924807d5
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment