I have a function:
function getMilk() {
if($condition == true)
return "Milk for you, madam";
return false;
}
Example 1:
if(getMilk())
echo getMilk();
Does the first example make PHP run for milk twice?
Example 2:
echo getMilk(); // don't check for milk first, just get it if they have it
If I was PHP I would rather get the second example. Then I wouldn't have to run to the store checking for milk, then running once more to get it.
Would example 2 be faster/better, or doesn't it matter?