By John Koster
The value function will return the default value of the supplied $value. Although this sounds redundant, if the supplied $value is an instance of the Closure class (an anonymous function), the function will be executed and the value will be returned. If the $value is not an instance of Closure, the value is simply returned.
#Signature
The signature of the value function is:
1function value(
2 $value
3);
#Example Use
Using value with an instance of Closure:
1$value = value(function()
2{
3 return 42;
4});
In the above example, $value would contain the integer 42, because it was returned from the supplied function.
The following example does not use an instance of Closure:
1$value = value(42);
Again, $value would contain the integer 42.
∎