简体   繁体   English

Codeigniter发送空白页

[英]codeigniter sends blank page

I faced today a strange problem wich I cannot explain. 我今天面对一个无法解释的奇怪问题。 The Environment: 环境:

  • Ubuntu 16.04 Ubuntu 16.04
  • Nginx 1.10 with php-fpm Nginx 1.10和php-fpm
  • php 7.0.8 的PHP 7.0.8

So I migrated from a hosted server with apache and php5 to this new Server. 因此,我从具有apache和php5的托管服务器迁移到了此新服务器。 The first tests were successful. 最初的测试是成功的。 The page was running and seemed to be fine. 该页面正在运行,看起来还不错。

Then I encountered the Problem, that some pages couldn't be called. 然后我遇到了问题,某些页面无法调用。 The HTTP response was 200 but the page was blank. HTTP响应为200,但页面为空白。 Chrome told me net::ERR_CONTENT_DECODING_FAILED Chrome告诉我网:: ERR_CONTENT_DECODING_FAILED

I found out, that the difference between working pages and the blank pages were, that the non-controller echoed json_encode() at the end; 我发现工作页和空白页之间的区别在于,非控制器在最后回显了json_encode();

This is my controller: 这是我的控制器:

public function some_controller()
{
     $result = ["test" => "abcde"];
     echo json_encode($result);
}

This will end with net::ERR_CONTENT_DECODING_FAILED 这将以net :: ERR_CONTENT_DECODING_FAILED结尾

This is my workarround: 这是我的工作环境:

public function some_controller()
{
     $result = ["test" => "abcde"];
     echo json_encode($result);
     exit();
}

So following is unclear: 因此,以下内容尚不清楚:

  1. Why I have to exit() my controller now? 为什么我必须现在退出控制器?
  2. What is CI doing after a Controller function is passed? 传递Controller函数后,CI会做什么?
  3. Why was that working with Apache and PHP5? 为什么要使用Apache和PHP5? What could be the difference now? 现在有什么区别?

Thank you all 谢谢你们

I found the problem by myself. 我自己发现了问题。 After installing php7.0-xml the issue went away. 安装php7.0-xml后 ,问题消失了。

But can anyone tell me why the xml module is required for JSON responses? 但是谁能告诉我为什么JSON响应需要xml模块吗? Maybe its not the JSON, it is codeigniter wich needs the XML Module (After the controller is passed)? 也许不是JSON,而是需要XML模块(通过控制器后)的codeigniter吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM