So, I have two classes:
class foo { } $foo = new foo(); class bar { global $foo; public function bar () { echo $foo->something(); } }
I want to access the foo methods inside all method panels without declaring them in each method inside the panel, for example:
class bar { public function bar () { global $foo; echo $foo->something(); } public function barMethod () { global $foo; echo $foo->somethingElse(); } }
I do not want to expand it. I tried using the var keyword, but it didn't seem to work. What should I do to access another "foo" class in all bar methods?
variables php global
Waleed khan
source share