문자열을 개체로 변환 할 때 문제가 있습니다.문자열을 대상으로 만드시겠습니까?
public function slikepoid($dire,$id)
{
$this->dire=$dire;
$this->id=$id;
$slike = $this->skupljanjeslika($this->dire);
$slikeid = array_filter($slike, function($el) {
return substr($el, 0, 2) == '$this->id-'; // Here is the problem !
});
return $slikeid;
}
나는이 오류가있어 :
치명적인 오류 : 여기에 기능입니다 $를 사용하여이 라인 8
개체 컨텍스트에서 내가 노력하지 않을 때 :
return substr($el, 0, 2) == ''.(string)$this->id;'-';
하지만 운이 없다 : (
PHP 5.3에서는 익명 함수 (클로저) 내에서'$ this'를 사용할 수 없습니다. PHP 5.4에서 그렇게 할 수 있다고 생각합니다. –
예, 문자열의 생성자를 변환하는 방법은 무엇입니까? –