I have create this helper in Helpers folder inside Http folder: when I call it in controller : it give me this error : Using $this when not in object context where I remove $this in function I get this error : Call to undefined function AppHttpHelperscheck_id() Answer check_id is a static function if you want to access it into
Tag: this
Call static method from instance in PHP, future deprecation?
While I understand the $this variable is not available when a method is called in a static context, to assist in decoupling my application components from one-another I figured it would make sense to call static methods from an instance. For example: Are there plans to deprecate this sort of functionality, or am I right to expect support for this
Why is the usage of $this in PHP necessary when referencing methods or variables in the same class?
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 I need to add $this to the method when it’s declared in the same class?” I didn’t really know how to answer. Maybe it’s because PHP has a global namespace and it you need to