What is the syntax to find out in method2 whether method1 one returned true or false?
class myClass{
public function method1($arg1, $arg2, $arg3){
if(($arg1 + $arg2 + $arg3) == 15){
return true;
}else{
return false;
}
}
public function method2(){
// how to find out if method1 returned true or false?
}
}
$object = new myClass();
$object->method1(5, 5, 5);
To do as you propose you could do it a few ways:
1) Call the method 1 inside method 2
2) Call it before method 2 (a bit weird to do it this way but possible and could be needed depending on context)
If you are only going to need the result of method 1 ONCE (thus the return value of method 1 doesn’t change) then and are going to call method 2 many times then you can be more efficient to do it outside of method 2 to save re running the same code (method 1) every time method 2 is called.