Is it possible in PHP setup a predefined function parameter to be a result of another function?
function f1() { return rand().'entropy'; }
#####
###
#
function f2($a=f1(), $b=Null) {
if($a==Null) $a='default';
return $a.$b;
}
. . You can't assign it directly, but you can "emulate" it the same way you are doing with the "default" string:
function f1() { return rand().'entropy'; }
function f2($a = Null, $b=Null) {
if ($a == Null) { $a = f1(); }
if ($a == Null) { $a = 'default'; }
return $a . $b;
}
. . Seeing that the f1()
always returns a string, the second if
in my code will never get executed. I just followed your code sample and as I understand this was just an example of how you can use the return of a function as a default value, ok?