0

我遇到了一个非常奇怪的问题。今天我尝试在我的 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();

?>

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

但是网上还是空的。。

有谁知道我做错了什么?

提前致谢!!

4

1 回答 1

0

@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();

?>

它有效!

谢谢!!!!

于 2014-03-25T07:12:21.700 回答