Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Test
- {
- public $var = 4;
- public function doStuff() {
- $this->var = 4;
- }
- public function testNoThis() {
- echo __METHOD__ . PHP_EOL;
- var_dump(array_keys(get_defined_vars()));
- }
- public function testThisGet() {
- echo __METHOD__ . PHP_EOL;
- var_dump(array_keys(get_defined_vars()));
- $this->var;
- }
- public function testThisSet() {
- echo __METHOD__ . PHP_EOL;
- var_dump(array_keys(get_defined_vars()));
- $this->var = 4;
- }
- public function testThisCall() {
- echo __METHOD__ . PHP_EOL;
- var_dump(array_keys(get_defined_vars()));
- $this->doStuff();
- }
- public function testThisUse() {
- echo __METHOD__ . PHP_EOL;
- var_dump(array_keys(get_defined_vars()));
- $foo = $this;
- }
- }
- $t = new Test();
- $t->testNoThis();
- $t->testThisGet();
- $t->testThisSet();
- $t->testThisCall();
- $t->testThisUse();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement