Non-static method App\Http\Helper::myFunction() should not be called statically

Updated at 30-Aug-2021, By samar

Non-static method AppHttpHelper::myFunction() should not be called statically

Hello everyone, in this post we will look at how to solve "Non-static method AppHttpHelper::myFunction() should not be called statically" in programming.

Error Non-static method App\Http\Helper::myFunction() should not be called statically occurs when you try to call the non static function as static. To remove this error you change the type of function declaration or you can change the method of calling the function
  • Change method from function myFunction() to public static function myFunction

    //Use
    public static function myFunction(){
        
    }
    //Instead of
    function myFunction(){
    }
    

    You have to change the function form function myFunction to public static function myFunction to avoid this error. Because you call this method statically (Helper::myFunction()) and you did not define function as a static function.

Back to code snippet queries related laravel