【发布时间】:2016-02-12 17:42:00
【问题描述】:
这就是我的类结构的样子(lib.php):
trait smartMethods{
function Numbers($length,$position){
echo $length.$position."\n";
}
}
class smartBrute {
Private $config,$smlist;
use smartMethods;
function init(){
foreach($this->config as $k => $v){
$inp = "";
foreach($v as $k2 => $v2){
($inp == "" ? $inp = $v2 : $inp .= ",".$v2);
}
$this->{$k}($inp); // Here Is Problem
}
} //EO init
} //EO Class
调用类(init.php):
$options["Numbers"] = Array(2,1);
$brute = new smartBrute($options);
$this->{$k}($inp); {$k}() 它可以工作,但我不明白如何在这种情况下传递参数。
【问题讨论】:
标签: class oop arguments traits