Reputation: 535
Iam calling a method from another method in the same class.I used to return value from the second method.but whenever am calling that function from first method,it prints the value that am returning from the second method,and it stops execution.Anyone please help me.
first method:
public function firstMethod(){
$this->secondMethod();
dd('ok');
}
second method:
public function secondMethod(){
return 'true';
}
when the execution begin..,it prints 'true'.Help please....thanks in advance :).
Upvotes: 0
Views: 1248
Reputation: 3780
If you need to continue after checking the returned value, then you can do this:
public function firstMethod(){
if (!$this->secondMethod()) return; // ends function and returns execution
dd('ok'); // executed if secondMethod() returns true
}
Upvotes: 1