Re: json_encode() behavior and the browser
| From: | Jo�o C�ndido de Souza Neto | Date: | Wed, 01 Sep 2010 13:23:54 +0000 |
| Subject: | Re: json_encode() behavior and the browser | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-307806@lists.php.net to get a copy of this message | ||
It can have something to do with your browser codification (UTF8,
ISO-8859-???).
--
João Cândido de Souza Neto
"Christoph Boget" <cboget@hotmail.com> escreveu na mensagem
news:AANLkTi=45-HEtO2MYhQ116GV6bfxvDBA_yXfzJNqKVV8@mail.gmail.com...
> I'm curious if the behavior of json_encode() is influenced by the
> browser at all. I have a page that returns search results. If I
> access the page and perform a search using Chrome, the following error
> shows up in the log:
>
> PHP Warning: json_encode() [<a
> href='function.json-encode'>function.json-encode</a>]: Invalid UTF-8
> sequence in argument in [PAGE] on line [LINE]
>
> If I access the page and perform a search, the exact same search using
> the exact same parameters, using Firefox then I get the expected
> results. When I var_dump() the return value of json_encode(), I see
> that it is a null in the case where I accessed using chrome but the
> expected string in the case where I accessed using firefox. In both
> cases, the input array is identical.
>
> Given the identical input and different output, the only thing I can
> figure is that the headers sent to the server as part of the request
> figure in to how json_encode() behaves. Is that the case? Or am I
> barking up the wrong tree?
>
> To be clear, I'm not talking about how the browser ultimately handles
> the json encoded data. I know there can be issues with that. I'm
> talking about the process before the data is even shipped to the
> browser -- about how json_encode() behaves when executed as part of
> the PHP script.
>
> thnx,
> Christoph