Json_encode - PHP gives an incomplete json string

My setup first: PHP 5.3.2 - with Suoshin and xCache lighttpd / 1.4.26

My code is too much to post here. I will talk about it.

The x.php file loads some PHP-Classe, runs them, performs some functions → gets an array of results.

If I print_r this array, I get the full result.

But I use json_encode, it cuts it every time at the same position. → json is not valid.
Example: print_r -

Array ( [test1] => Array ( [test2] => 2 [test3] => Array ( [test4] => 4 ) ) ) 

json -

 {"test1":{"test2":2,"test3":{"te 

The error log reports the following:

 (mod_fastcgi.c.2582) unexpected end-of-file (perhaps the fastcgi process died): pid: 16708 socket: unix:/tmp/php5.socket-1 (mod_fastcgi.c.3382) response already sent out, but backend returned error on socket: unix:/tmp/php5.socket-1 for /x.php?, terminating connection 

The question is, how can I track what an error is? Or does anyone know what the problem is?

+4
source share
1 answer

Sounds like a buffering problem. Ensure that the response buffer is flushed before closing the connection.

+2
source

Source: https://habr.com/ru/post/1384932/


All Articles