[英]Dynamic Function Call PHP
I have a very specific question: is the following code possible in one line? 我有一个非常具体的问题:下面的代码是否可以在一行中显示? Or is there a beter way to do the same?
还是有更好的方法来做到这一点?
$key = rand(1,100);
$temp = 'GetObjects'.ucfirst($key).'Array';
$objects = $this->module->$temp();
Like this: 像这样:
$objects = $this->module->'GetObjects'.ucfirst($key).'Array'();
Maybe 也许
$objects = $this->module->{'GetObjects'.ucfirst($key).'Array'}();
or 要么
$objects = call_user_func(array($this->module, 'GetObjects'.ucfirst($key).'Array'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.