문제

오류가있는 경우 부분은 다음과 같습니다.

치명적인 오류 : 6 행 6의 객체 컨텍스트에 있지 않을 때 $ this 사용

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"를 전달하는 것을 알지 못했습니다.

조언 : 단순히 "$ this"를 "$ somethingelse"로 바꾸십시오.

다른 팁

당신은 통과 할 수 없습니다 $this 절차 적 기능으로. $this 예약 변수입니다.

내 의견에 따라. 당신은 사용하고 싶습니다 $this 통과 된 변수와 PHP는 클래스 메소드 외부 신체를 허용하지 않습니다.

function DoEvents($obj) {

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

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

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

먼저 물체를 만들어야합니다.

   $object=new Myobject;
   DoEvents($object);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top