I have a class with a name Parent
and a class Child
that inherits Parent
class.Parent
class has a property filename
with value testfile
.In the first step I change the value of this property for example on anothertestvalue
in Parent
class testFileame
method.Then I try to call method log
from Child
class and this method try to get filename
property from Parent
class.
class Parent {
public $filename = 'filename';
public function setFilename() {
$this->filename = 'anotherfilename'
}
public function log($message, $this->filename) {
//here filename from Child class has value 'filename' but I expect 'anotherfilename'
}
}
class Child extends Parent {
$this->log("somemessage");
}
I expect to get anothertestvalue
value but method uses testfile
.Can someone explain what happens?