dpnfjx755573 2014-11-25 01:40
浏览 54
已采纳

PHP输出缓冲区获取白屏并且方法返回时没有错误

I have been using PHP for a very long time and for some reason migrating to a new server has caused a White Screen of Death. Obviously it must be because of a version difference. I have been using the same output buffer pattern for years.

Typically...

ob_start();
?>
    //HTML...
<?php
$output = ob_get_clean();
ob_flush();

return $output;

Recently I had discovered some problems in my normal/newer versions of PHP (5.4+ On my WAMP I think) while returning HTML sections and passing them around between views (I use MVC). They were displaying entirely to the screen and not being saved in the buffer at all. I found out that I needed a necessary flag in my ob_start() to let it know that buffers can be removed.

Like so ob_start(null, 0, PHP_OUTPUT_HANDLER_REMOVABLE);

However now that my page is live and not on WAMP the entire page now breaks and shows full whitescreen. I have all error reporting turned on and still nothing. Nothing showing up in logs, etc. So I have done a large series of echo "test"; die; to see at what line it is breaking and sure enough all is well when I remove the buffered sections that pass finished HTML blocks between views.

I need to figure out how to properly have my sections returned.

  • 写回答

1条回答 默认 最新

  • doulu3399 2014-11-25 12:17
    关注

    You don't need ob_flush() in this situation because ob_get_clean() has already closed the output buffer.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 网络科学导论,网络控制
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)