Parent Object in php

后端 未结 6 1643
抹茶落季
抹茶落季 2020-12-15 08:57

is there a way to traverse an object to get the parent object data? With \"parent object\" I don\'t mean the parent class, but literally object. Here an example, in a javasc

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-15 09:42

    No.

    You can access variables from the superclass using $this:

    foo = 'hello';
        }
    }
    
    class B extends A {
        public function printFoo()
        {
            echo $this->foo;
        }
    }
    
    $b = new B();
    $b->printFoo();
    ?>
    

提交回复
热议问题