0

With the code:

function basic($test='David') {
    return "Test='".$test."';";
}

function using($test) {
    return basic($test);
}

echo using();

Suppose I din't create the function basic but I wanna propagate the default parameter [mind the difference between parameter and argument: What's the difference between an argument and a parameter? ]

In English: say basic is encapsulated, I don't know of the default value 'David' but I wanna be able to call using without passing an argument. But the output to be David; if you feel me?

But hey without mentioning David in the using function. I thought null value will do it or as blank as I did in the code sample.

My question is: is there a [default] value that represent the absence of the argument so that the default is in effect for a remote function that you don't know it's default value?

This question is simple but what of a complex function that you can't trace the processing of the argument to derive [~suggest] it's default. How can we have a pronoun default? -If you get me!

das Pro
  • 5
  • 3

1 Answers1

0
function using($test = null) {
    if(!$test)
        return $this->basic();
    return $this->basic($test);
}
TsV
  • 629
  • 4
  • 7
  • I'm not sure to accept this as an answer unless it is the ultimate solution. I was hoping for a value or class or type without my own logic [if - statement] to delegate [~meta] the default. – das Pro Sep 05 '18 at 17:45
  • I accepted it, just as I feel it is the most real solution but I believe in an ideal ultimate solution. So if you come across, do share..!? Thanks as of yet and in advance. – das Pro Sep 05 '18 at 18:01