dongpao1926 2014-12-01 22:05
浏览 55
已采纳

PHP ob_gzhandler额外的字符

I have a blended website where we have an ExpressionEngine CMS with a Magento store. In our EE site, I have a template where I call a plugin to retrieve the store cart info. We use Magento's authentication so the logged in user is the Magento user.

We want to show something like this:

first

The code in the plugin connects to Magento, gets the loggedin user, if they are logged in and sets the number of cart items.

This is the HTML that the plugin is supposed to return to the template:

<span class="carticon">(0)</span><a href="http://www.example.com/store/checkout/cart/">My Cart</a><span>Welcome, MB34!</span><a href="http://www.example.com/store/customer/account/logout/">Logout</a>

But, if I enable gZip on ExpressionEngine, I get the ERR_CONTENT_DECODING_FAILED exception because Magento doesn't have built-in gZip. Currently we do not have mod_deflate enabled so how would EE be able to gZip? It has to be through the ob_gzhandler.

Now, if I modify my plugin to use ob_gzhandler like this:

ob_start("ob_gzhandler");
echo trim($result);
ob_end_flush();

I get extra characters at the end of the output:

second

Any ideas what is causing this and how to fix it?

We will be enabling mod_deflate soon; will that fix it? I mean I won't have to use the ob_gzhandler then, right?

  • 写回答

2条回答 默认 最新

  • dongqun1656 2014-12-01 22:09
    关注

    When using ob_gzhandler its important that you don't mix content with other encodings. By forcing ob_end_flush() you may be causing this buffer to terminate before you are actually done sending content. A simple empty line by the end of the file may be causing this. I suggest you skip ob_end_flush() and let the buffer end naturally when your PHP script terminates.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?