PHP Fatal error: Using $this when not in object context

后端 未结 9 2266
日久生厌
日久生厌 2020-11-22 03:48

I\'ve got a problem:

I\'m writing a new WebApp without a Framework.

In my index.php I\'m using: require_once(\'load.php\');

9条回答
  •  臣服心动
    2020-11-22 04:15

    When you call the function in a static context, $this simply doesn't exist.

    You would have to use this::xyz() instead.

    To find out what context you're in when a function can be called both statically and in an object instance, a good approach is outlined in this question: How to tell whether I’m static or an object?

提交回复
热议问题