문제

I have a problem which is really brain-cracking. I would like to use the $this variable inside a function. As long as it is the function parameter variable, there is no problem. But when I change the code to assign it inside, it is no longer working (blank page when direct opened, AJAX responds with Internal Server Error). The rest of the code inside the function uses the variable $this, and perfectly works in the second way.

The full script is an AJAX e-mail sender for a WordPress site, using global $wpdb.

Am i missing something or is it too late night to see the mistake? :)

NOT WORKING

function lookup_product($in){
    $this = $in;

    echo $this;
}

WORKING

function lookup_product($this){

    echo $this;
}
도움이 되었습니까?

해결책

$this is a predefined variable in PHP.

http://php.net/manual/en/language.oop5.basic.php

Change the var $this to something else.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top