I have a class CalculatePrice. Running this code:
$calc = new CalculatePrice( 10, 20 );
print_r ( $calc->do() );
The do() method returns a different class called PriceObj. If I ran the code echo $calc->do() then I get an error: Object of class PriceObj could not be converted to string.
My question is: how can I still return an object from the do() method but when running an echo to it, it returns a string or even simpler; true or false? Is this possible?
return $calc->do()and in your code echo that desired property or call one of its functions (and that one willechowhat you want)