我正在尝试设置属性并将其用于另一个功能。
我有
while($texts->employees()){
$employee = $employees->get();
switch($employee->getInfoType()){
case 'email':
$this->buildemail($employee);
break;
case 'Name':
$this->buildName($employee);
break;
case 'Numbers':
$this->buildNumbers($employee);
break;
}
function buildEmail($employee){
$this->email=$employee->getEmail(); //get the email.
}
function buildName($employee){
$this->Name=$this->getName(); //get the name
$this->employeeInfo=$this->email.$this->name; //combine the email and numbers.
//$this->email is '' becasue it's only defined in buildEmail().
}
function buildNumbers($employee){
$this->numbers=$this->getNumbers();
}
我似乎无法进入$this->email
buildName 方法,因为this->email
在方法中定义buildemail
。我需要使用 switch,因为每种方法都有很多代码。有没有办法做到这一点?