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

Notice: This thread is very old.
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

matopeto
Member | 395
+
0
-

show the code.

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

David Matějka
Moderator | 6445
+
0
-

try var macro

{var $r = $decodedResponse->body}
monstah
Member | 3
+
0
-

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

Chris