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

Test with () and changed string with ucwords()

parent eed2a056
Loading
......@@ -11,7 +11,21 @@ class Mic
// Creating methods..
public function setLight($light){
print($light);
print($this -> light);
print($light);//Returns parameter's value
// $this keyword is used to specify the variable inside class.
print($this -> light);//Returns Object variable value.
}
// Call and change model name to first word as uppercase
public function setModel($model){
// Store $model values to model with $this.
$this -> model = ucwords($model); //ucwords() converts 1st letter string as uppercase.
return $this-> model;
}
public function getModel(){
print($this-> model);
}
}
......@@ -25,13 +25,19 @@
$mic1 = new Mic();
$mic2 = new Mic();
$mic1->brand = "Toyota";
$mic1->brand = "Switf";
$mic2 -> brand = "Hyundai";
// Adding values to $light with $this keyword
$mic1 -> light = "RGB";
$mic1 -> setLight("yellow");
$mic1 -> setModel("toyata innova");
$mic1-> getModel();
printf("mic1 = %s\n", $mic1 -> brand);
printf("mic2 = %s", $mic2 -> brand);
?>
</pre>
\ No newline at end of file
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