【问题标题】:ob_get_contents NO contents on serverob_get_contents 服务器上没有内容
【发布时间】:2014-03-22 20:58:42
【问题描述】:

我遇到了一个非常奇怪的问题。 今天我尝试在我的 PHP 应用程序中实现缓存。

它在我的本地 WAMP 服务器(Windows 8)上就像一个魅力。 但是不能在线使用。

因此我不知道我做错了什么。

代码有点像:

<?php

function write_cache(){
$contents = ob_get_contents();

/// do something with contenst (like writing it..
}

$tpl_content = 'loooooong string'; // gets filled throughout the application

echo $tpl_content;

/// should be filling the cache
write_cache();

?>

这应该可行。我回显它,因此它在缓冲区中。 而且我在某个地方做得正确,因为它在本地工作。

但在线它仍然是空的..

有谁知道我做错了什么??

提前致谢!!

【问题讨论】:

  • 您的ob_start() 电话在哪里?
  • 如果需要。那么这将是解决方案。明天试试这个!如果这能解决它会很棒。我仍然有点惊讶为什么这在本地有效。

标签: php caching ob-get-contents


【解决方案1】:

@faintsignal

你在哪里对! ob_start();失踪。 WAMP 服务器上可能不需要它。

但在 LAMP 服务器上是必需的。

代码现在看起来像:

<?php

ob_start();

function write_cache(){
$contents = ob_get_contents();

/// do something with contenst (like writing it..
}

$tpl_content = 'loooooong string'; // gets filled throughout the application

echo $tpl_content;

/// should be filling the cache
write_cache();

?>

而且有效!!

谢谢!!!!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-25
    • 2012-08-16
    • 1970-01-01
    • 2014-12-23
    • 2013-09-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多