Access class property from outside of class

前端 未结 6 510
感情败类
感情败类 2021-01-22 18:41

Suppose I had the following class:

class MyClass {
    public function Talk() {
        $Say = \"Something\";
        return $Say;
    }
}

I th

6条回答
  •  我在风中等你
    2021-01-22 19:17

    You'd need to declare that var before your functions, eg

    class MyClass {
      public $say;
      function Talk() {
        $this->say = "something";
      }
    }
    

    and then

    $Said = "He ".$Inst->$say;
    

提交回复
热议问题