public function getSalarya()
{
$res = $this->test();
return $res;
}
## private function test(){
$res = $this->salary;
if ($this-> dept == 'Finance Department') {
$res = 'How dare you check the people around the boss? You don't want to mess around anymore';
}
It is around 18:26 in the video. We use test() to encapsulate the filtering mechanism of the previous if statement, and then use the public getSalary() to call the private test(). I found that salary getSalary() did not return the value we needed to get. Later I found that getSalary() wants to return a value, so it needs to return the value through return in getSalary(). Return $res; is no problem. But the value passed by test() must be received through the variable $res in getSalary(). Just write $res = $this->test(); and then go back and check test(), and find that test() also needs a return to pass out $res in test(). Just add return $res; in test() and it will run.
Can you at least tell me what the problem is? How can I help you answer it?