Ölümcül hata: $ bu zaman kullanma değil nesne bağlamında

3 Cevap php

hata sahip olursa burada parçasıdır.

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

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

Thanks a lot! takdir!

3 Cevap

$ Bu sadece yöntemlerde değil, fonksiyonlarında mantıklı

Bu ok

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

Bu değil

function some() {
    $this->

/ / Edit: o "$ this" parametre olarak geçer fark etmedi

tavsiye: sadece "$ this" "$ somethingelse" ile değiştirin

Bir usul işleve $this geçemez. $this ayrılmış bir değişkendir.

Önce nesneyi yapmak zorunda.

   $object=new Myobject;
   DoEvents($object);