Why is the usage of $this in PHP necessary when referencing methods or variables in the same class?

后端 未结 5 2025
你的背包
你的背包 2021-01-16 04:24

I was explaining to a Java developer why his method call wasn\'t working. He just needed to add $this->method_name();

He then asked me, \"Why do

5条回答
  •  误落风尘
    2021-01-16 04:56

    This is not unusual. Python, Javascript, Perl (and others) all make you refer to a this or self when dealing with objects.

提交回复
热议问题