Php ob\u获取\u内容服务器上没有内容
我遇到了一个非常奇怪的问题。 今天我尝试在PHP应用程序中实现缓存 在我的本地主机WAMP服务器Windows8上,它就像一个符咒。 但它在网上不起作用 因此,我不知道我做错了什么 代码有点像:Php ob\u获取\u内容服务器上没有内容,php,caching,ob-get-contents,Php,Caching,Ob Get Contents,我遇到了一个非常奇怪的问题。 今天我尝试在PHP应用程序中实现缓存 在我的本地主机WAMP服务器Windows8上,它就像一个符咒。 但它在网上不起作用 因此,我不知道我做错了什么 代码有点像: <?php function write_cache(){ $contents = ob_get_contents(); /// do something with contenst (like writing it.. } $tpl_content = 'loooooong string'
<?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_启动;他失踪了。
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();
?>
而且很有效
谢谢 您的ob_开始呼叫在哪里?如果需要。那么这就是解决办法。我明天会试试这个!如果这能解决问题那就太好了。不过,我还是有点惊讶为什么这在本地有效。