考虑类abc
class abc{
public function xyz(){
/*Some processing here*/
return true;
}
};
假设我不直接知道方法的名称,而是将其名称存储在变量中,那么如何调用该方法?
最佳答案
<?php
class abc{
public function xyz(){
/*Some processing here*/
return true;
}
};
$method='xyz'; // Define your method name from database
$a= new abc();
$a->$method(); // call method
?>
请引用上面的代码吗?
关于PHP - 调用名称存储在变量中的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37894459/