note 117506 rejected from language.oop5.paamayim-nekudotayim by cmb
| From: | cmb@php.net | Date: | Sat, 20 Jun 2015 09:39:28 +0000 |
| Subject: | note 117506 rejected from language.oop5.paamayim-nekudotayim by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-202911@lists.php.net to get a copy of this message | ||
Note Submitter: mohamed dot qabbani at gmail dot com
----
How can i access property 'var' in class 'OtherClass' from inside class like the
method myFunc (parent::myFunc();)
<?php
class MyClass {
public $var = 'A';
protected function myFunc() {
echo "MyClass::myFunc()\n";
}
}
class OtherClass extends MyClass {
public $var = 'B';
// Override parent's definition
public function myFunc() {
// But still call the parent function
parent::myFunc();
echo "OtherClass::myFunc()\n";
}
}
$class = new OtherClass();
$class->myFunc();
?>