1
I made a request and the result brought $result. But I wanted to access inside the string as object and this error appears. I saw similar mistakes in other questions, but it wasn’t clear to me.
echo $result;
echo "<br>";
echo var_dump($result);
echo "<br>";
echo json_decode($result);
{"response":{"dsLOGIN":{"dsLOGIN":{}}}} string(39) "{"response":{"dsLOGIN":{"dsLOGIN":{}}}}"
Error:
Catchable fatal error: Object of class stdClass could not be converted to string in
What happens if you make one
print_r($result);
?– Thiago Santos
{"response":{"dsLOGIN":{"dsLOGIN":{}}}}
- The same line as echo $result @Thiagosantos– user3453562
In which line are you making the mistake? In this:
echo json_decode($result);
?– Thiago Santos
Yeah, right on it.
echo json_decode($result);
@Thiagosantos– user3453562
json_decode($result);
returns a PHP Object, and with an ECHO you try to write that Object as String, which is causing this error.– Thiago Santos