加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

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

发布时间:2020-12-13 13:12:04 所属栏目:PHP教程 来源:网络整理
导读:这是错误的部分. 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
这是错误的部分.

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”

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读