What do this reference symbol (&)
do in &methodName()
method?
Is it necessary?
Is this called a reference by method
?
class TestClass
{
private $value;
public function __construct()
{
$this->value = 5;
}
public function &methodName(){
return $this->value;
}
}
echo (new TestClass())->methodName(); //Outputs 5;