I have a simple class... I need to update public $token if it is setted. My code is:
<?php
class Amazon {
public $token = '';
public function update($key = '', $value = '')
{
if(isset($this->"{$key}"))
{
$this->"{$key}" = $value;
}
return true;
}
}
But I am getting this error: Parse error: syntax error, unexpected '"', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$'
Try it without the quotes. $this->{$key}