Access class property from outside of class

前端 未结 6 436
感情败类
感情败类 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:10

    You can use

    $said = "He" . $Inst->Talk();
    

    in this case, or you can class

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

    and call

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

提交回复
热议问题