When does json_decode doesn't work as object?

I learned that


will decode the json string as object

json_decode($userinfo, true);

will decode the json string as array…

For some reason I’m able to extract the json string as array but when I try it to do it as object it breaks. Do you have any idea why?


crap!! the problem was that I was putting echo in front of it when it was an object

echo $userinfo = json_decode($userinfo); 

but this works when it’s an array… like

echo $userinfo = json_decode($userinfo, true);

it prints Array…

It would be great if the first one printed object or something instead of breaking down…