I am trying to understand the main difference between returning false from an instruction as opposed to an error echo that allows the user to correct their representation.
Let's take the following function, which is used to get the URL of the conversion API in Google, and analyze three more parameters $amount, $from, $to . I use explode to get the numeric values โโreturned by the API "" .
function currency_convert($googleCurrencyApi, $amount, $from, $to) { $result = file_get_contents($googleCurrencyApi . $amount . $from . '=?' . $to); $expl = explode('"', $result); if ($expl[1] == '' || $expl[3] == '') { return false; } else { return array( $expl[1], $expl[3] ); } }
What is the advantage of returning false if the statement is true compared to the echo from the construct message? I see a false return regularly used in many forums, etc.
Thanks in advance.
source share