내 프로그램에서 다음 코드를 사용하고 있습니다.php call_user_func_array() 경고
class A {
function __call($fname,$arguments)
{
$methods = array('get', 'set');
foreach ($methods as $method) {
if(strstr($fname,$method))
{
$fname = str_replace($method, "", $fname);
$function = $method."method";
if($method == "set")
{
call_user_func_array("setmethod", array($fname,$arguments[0]));
}
if($method == "get")
{
call_user_func_array("getmethod", $fname);
}
break;
}
}
}
function setmethod ($key,$value)
{
$this->$key = $value;
}
function getmethod($key)
{
return $this->$key;
}
}
나는이
처럼 warrning 얻고있다 "경고 : call_user_func_array는() 매개 변수 1, 기능은 'SETMETHOD'유효한 콜백 될 것으로 기대를 찾을 수 없거나 유효하지 않은 함수 이름이 아닙니다"
과 프로그램 멈춤 아무것도 표시되지 않습니다.
그래서, 내가 그것을이 클래스의 일부이다 걸릴
콜백을 제시 배열을 사용하여? – vollie
'call_user_func_array'는 당신이 클래스 컨텍스트에 있다고 마술처럼 인식하지 않습니다. 'setmethod'대신'array ($ this, "setmethod")'를 사용하십시오. – Yoshi