我已经在这个网站和Google上进行了搜索,最终创建了这个帐户...
我需要有关php,特征和类的帮助。我有这2个不同的特征,其中一些方法具有相同的名称。
问题取决于我需要他们两个!我不能代替...
这是一个示例代码:http : //sandbox.onlinephpfunctions.com/code/b69f8e73cccd2dfd16f9d24c5d8502b21083c1a3
trait traitA {
protected $myvar;
public function myfunc($a) { $this->myvar = $a; }
}
trait traitB
{
public function myfunc($a) { $this->myvar = $a * $a; }
}
class myclass
{
protected $othervar;
use traitA, traitB {
traitA::myfunc as protected t1_myfunc;
traitB::myfunc as protected t2_myfunc;
}
public function func($a) {
$this->myvar = $a * 10;
$this->othervar = t2_myfunc($a);
}
public function get() {
echo "myvar: " . $this->myvar . " - othervar: " …Run Code Online (Sandbox Code Playgroud)