htmlspecialchars() parameter warning when I try to decode a json-String

4 years ago

monstah
Member | 3
+
0
-

the exact message: “htmlspecialchars() expects parameter 1 to be string, object given in ../nette.min.inc”

As the headline determines, I ve got a warning, when I try to decode a String into a json-Object in PHP. Any suggestions? I'm just using the method json_decode() with a json-String(!).

thx for the replies,

Chris

4 years ago

matopeto
Member | 400
+
0
-

show the code.

4 years ago

monstah
Member | 3
+
0
-

Hello,

I think I “fixed” it. Fortunately it had nothing to do with the decode-method. I tried to create a variable inside the latte template language as followed:

{$r = $decodedResponse->body}

and switched to the standard php version instead:

<?php
    $r = $decodedResponse->body;
?>

The warnings are gone and I am new to latte, so I think latte was trying to print a php-Object and gave me this warning? But it shouldn't be impossible to create a variable in latte at least, or am I wrong? thx for replies,

Chris

4 years ago

David Matějka
Moderator | 5961
+
0
-

try var macro

{var $r = $decodedResponse->body}

4 years ago

monstah
Member | 3
+
0
-

oh boy, that did the trick. thanks! Sry for the bug report.

Chris