Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Test
- {
- private $foo;
- public function __construct($foo)
- {
- $this->foo = $foo;
- }
- private function bar()
- {
- echo 'Accessed the private method.';
- }
- public function bez(Test $other)
- {
- // We can change the private property:
- $other->foo = 'hello';
- var_dump($other->foo);
- // We can also call the private method:
- $other->bar();
- }
- }
- $test = new Test('test');
- $test->baz(new Test('orter'));
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement