This may sound like a dumb question, but does assigning a variable to a function mean it only calls the function ONE time, and can be reused unlimited times without making an additional call to the function or does it still call the function multiple times?
is this:
$variable = function_name();
echo $variable;
echo $variable;
the same as this:
echo function_name();
echo function_name();
I understand both situations are ultimately displaying the same bit of information, but I'm curious if that bit of data is fetched one time and reused many, or if it's fetched upon each echo.
So does assigning a variable to a function mean function_name();
does the work only ONE time and the variable just recycles the data for later usage or does function_name();
actually do the work TWO times?
Is it better practice to assign variables or just directly call the function each time it needs to be used?