致命错误:不在对象上下文中使用 $this [英] Fatal error: Using $this when not in object context

查看:34
本文介绍了致命错误:不在对象上下文中使用 $this的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是有错误的部分.

致命错误:不在时使用 $this对象上下文/pb_events.php在第 6 行

Fatal error: Using $this when not in object context in /pb_events.php on line 6

第 6 行是:$jpp = $this->vars->data["jpp"];

function DoEvents($this) {

    global $_CONF, $_PAGE, $_TSM , $base;

    $jpp = $this->vars->data["jpp"];

    $cache["departments"] = $this->db->QFetchRowArray("SELECT * FROM {$this->tables[job_departments]}");
    $cache["locations"] = $this->db->QFetchRowArray("SELECT * FROM {$this->tables[job_location]}");
    $cache["names"] = $this->db->QFetchRowArray("SELECT * FROM {$this->tables[job_names]}");
    $cache["categories"] = $this->db->QFetchRowArray("SELECT * FROM {$this->tables[job_categories]}");

非常感谢!欣赏!

推荐答案

$this 只在方法中有意义,在函数中没有意义

$this only makes sense in methods, not in functions

没关系

class Foo {
     function bar() {
          $this->...

这不是

function some() {
    $this->

//没有注意到他将$this"作为参数传递

// edit: didn't notice he passes "$this" as parameter

建议:只需将$this"替换为$somethingElse"

advice: simply replace "$this" with "$somethingElse"

这篇关于致命错误:不在对象上下文中使用 $this的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆