Help understanding PHP5 error

后端 未结 4 485
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-28 08:29

In short.. question is... \"Say what?\" To expand... \"I don\'t get the error\"

Strict Standards: Non-static method Pyro\\Template::preLoad() should not b

4条回答
  •  醉话见心
    2021-01-28 08:51

    Like everyone said, the you called the function with as a static method:

    Template::preLoad(xxx)

    The :: means static in PHP. Functions are typically called as static :: or object -> calls.

    The function definition is one or the other:

    public static function preLoad($template, $page)

    Called like: Template::preLoad('admin/courses/index', $this->data);

    OR

    public function preLoad($template, $page)

    Called like Template->preLoad('admin/courses/index', $this->data);

    For reference, a static function is able to be called without instantiating an object. If your function doesn't need an object to run, you could make it static. Basically, this means you can't reference $this in a static method. It will run with the given inputs without having to construct the object.

提交回复
热议问题