Need some help please. I am getting a 'Trying to get property of non-object' error in a function call that looks at an array.
The array I am calling is
$var = array(
"variableA" => "abc123",
"variableB" => "123456789"
);
The function I am using is
public function getJson($var)
{
$resource = sprintf("/info/%s/%s/json", $var->variableA, $var->variableB);
return $this->_restCall('GET', $resource);
}
I cant understand why the array values are not being passed through?
Could someone please help?
$var
is an array not an object. So you need to use array syntax, not object syntax:
public function getJson($var)
{
$resource = sprintf("/info/%s/%s/json", $var['variableA'], $var['variableB']);
return $this->_restCall('GET', $resource);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.