I'm trying to provide a member variable as a default value for a class method.
I know it's impossible to use a variable as a default value for a non-class function, but it seems like there should be a way to do this within a class.
There must be a way to do it - perhaps I just have the wrong syntax:
class test{
private $test = '';
__construct(){
$this->test = "whatever";
}
function getTest($var = $this->test){
echo $var;
}
}
but this throws an error saying something like:
$this->test as a function argument default value is not allowed. unexpected T_VARIABLE.
Any thoughts?