There is no problem here but this has been on my mind and I couldn't find the answer anywhere. If I have a variable being populated with a function, does the function only get called when that variable is referenced? Here's and example:
function foo(){
$foo = "Foo";
return $foo;
}
$foo = foo();
echo $foo;
In that example I am referencing $foo outside of the function with echo. If I weren't to reference that variable would foo() still be called?
I guess it doesn't really matter I was just wondering.
$foo = foo();, you're saying assign that variable to the result of evaluating that function. It will assign it right then and there, so yes, the function will be run.