How to call a method of a class?

前端 未结 1 1349
悲&欢浪女
悲&欢浪女 2021-01-11 13:06

I got 2x public functions in a class that must call 1 private function with different parameters also in the same class... for some reason it tell me that it can\'t find the

1条回答
  •  甜味超标
    2021-01-11 13:40

    You have to use $this to refer to the instance and the T_OBJECT_OPERATOR to access/mutate/call members/methods of an instance, e.g.

    $this->do();
    

    Please go through the

    • Chapter on Classes and Objects in the PHP Manual and
    • What is the point of having $this and self:: in PHP?

    0 讨论(0)
提交回复
热议问题