So I have two classes like this:
class foo {
/* code here */
}
$foo = new foo();
class bar {
global $foo;
public function bar () {
echo $
The short answer: nope, there is no way to implement what you want.
Another short answer: you're working with classes in "wrong" way. Once you selected Object Oriented paradigm - forget about "global" keyword.
The proper way of doing what you want is to create an instance of foo
as member of bar
and use it's methods. This is called delegation
.