function mymethod(){
echo “My property is “.$this->myproperty.” and my function is mymethod()<br/><br/>”;
}
function get_mymethod() {
return $this->mymethod();
}
}
$my_statement = new this;
$my_statement->get_mymethod();
$my_second_statement = new this;
$my_second_statement->myproperty = “Roger”;
$my_second_statement->get_mymethod();
?>
More Advanced Note:
Generally, $this-> is always used to reference methods within a class. You cannot name an oblect $this without getting an error.
Error Example:
You make a new object with the name $this = new myobject;
$this = new myobject;
$this->get_mymethod();
$this->myproperty = ”Bill”;
Output:
Fatal error: Cannot re-assign $this in C:\wamp\www\ABOOK\OOP\MY_OOP\this.php on line 17
© 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