PHP OOP properties can be named inside or outside the class. When you create an object, it gets the property name from within the class. Howvere, when you rename an object ouside the class, it will override the previous name for that property.
The code below shows 2 new instantiated objects;
$statement1 = new myclass;
$statement2 = new myclass;
Note how the text for the property name from each object is different from each other when the get_my_method() method is triggered?
function my_method(){
echo “My property name is “.$this->my_prop.” and my function is my_method()<br/><br/>”;
}
function get_my_method() {
return $this->my_method();
}
}
$statement1 = new myclass;
$statement1->get_my_method();
$statement2 = new myclass;
$statement2->my_prop = “Roger”;
$statement2->get_my_method();
© 2018 ALL Rights Reserved | Sitemap
Vancouver | North Vancouver | Burnaby | Richmond | Coquitlam | Port Coquitlam | Surrey | Langley | Maple Ridge | Mission | Abbotsford | Kamloops | Kelowna | Victoria | Squamish | Whistler | Pemberton