php – 致命错误:在不在对象上下文中时使用$this

前端之家收集整理的这篇文章主要介绍了php – 致命错误:在不在对象上下文中时使用$this前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这是错误的部分.

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]}");

非常感谢!欣赏!

$这只在方法中有意义,而不在函数

还行吧

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

这不是

function some() {
    $this->

//编辑:没注意到他将“$this”作为参数传递

建议:简单地用“$somethingElse”替换“$this”

原文链接:https://www.f2er.com/php/136682.html

猜你在找的PHP相关文章