I have a question about how PHP classes relate to each other. Specifically, I am hoping to discern if a certain practice is unfavorable. In my example I have two classes, 'foo' and 'bar'.
class bar {
function talk () {$this->talk = 'Hello!';}
}
class foo {
function foo () {
bar::talk();
self::talk();
}
function talk () {echo $this->talk;}
}
$foo = new foo(); // This will echo 'Hello!' to the screen
echo '<p><pre>';
var_dump($foo);
If you run the posted code, the property 'talk' is assigned to object 'foo' even though the code is in object 'bar'. Or stating it another way, by calling bar::talk(); from within the context of object 'foo', I am able to utilize the functionality of object 'bar' within the context of object 'foo'. I never instantiate 'bar' with the new keyword.
So my question is whether or not this is a bad or non-standard OOP practice. I am doing some development this way but before I go much further I want to know if there is some big no-no or caveat that I am missing.