I have a JSON object like below, which is stored in a variable called $product.
{"id":30} When I try to access the stored value though, I get the following error:
Trying to get property of non-object
Here is what I am doing:
echo $product->id; Alright folks, sorry for the wild goose chase. Apparently $products was an array and not a JSON data, which is really odd because print_r($products) and echo $products gave different results.
The results can be viewed here:
I am using Laravel, and usually laravel returns a nice JSON object from an SQL query, I must have changed something somewhere, which is why this happened. Thanks.
