I have this method:
public function setVariable($variable, $value = null)
{
$variables = json_decode($this->variables);
if(is_array($variable) || is_object($variable))
foreach($variable as $key => $value)
if(in_array($key, $this->variableNames))
$variables[$key] = $value;
else
$variables[$variable] = $value;
$this->variables = json_encode($variables);
$this->save();
}
But, if I call the method like this:
setVariable(['test' => 'test', 'bla' => 'bla'])
It return this error:
ErrorException in User.php line 60:
Illegal offset type
Line 60 is this line:
$variables[$variable] = $value;
But, why it return the error? I check if $variable is array or object, But it continues return this error. Why?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire