Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class A
- {
- private $name;
- public function __construct()
- {
- $this->name = 'Some Name';
- }
- public function getName()
- {
- return $this->name;
- }
- }
- class B
- {
- private $a;
- public function __construct(A $a)
- {
- $this->a = $a;
- }
- function getNameOfA()
- {
- return $this->a->getName();
- }
- }
- $a = new A();
- $b = new B($a);
- $b->getNameOfA();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement