• <i id='S8s2b'><tr id='S8s2b'><dt id='S8s2b'><q id='S8s2b'><span id='S8s2b'><b id='S8s2b'><form id='S8s2b'><ins id='S8s2b'></ins><ul id='S8s2b'></ul><sub id='S8s2b'></sub></form><legend id='S8s2b'></legend><bdo id='S8s2b'><pre id='S8s2b'><center id='S8s2b'></center></pre></bdo></b><th id='S8s2b'></th></span></q></dt></tr></i><div id='S8s2b'><tfoot id='S8s2b'></tfoot><dl id='S8s2b'><fieldset id='S8s2b'></fieldset></dl></div>
  • <small id='S8s2b'></small><noframes id='S8s2b'>

    <tfoot id='S8s2b'></tfoot><legend id='S8s2b'><style id='S8s2b'><dir id='S8s2b'><q id='S8s2b'></q></dir></style></legend>
      • <bdo id='S8s2b'></bdo><ul id='S8s2b'></ul>

        标头如何与 PHP 中的输出缓冲一起使用?

        时间:2023-11-30
          <tbody id='dpVyB'></tbody>

        • <i id='dpVyB'><tr id='dpVyB'><dt id='dpVyB'><q id='dpVyB'><span id='dpVyB'><b id='dpVyB'><form id='dpVyB'><ins id='dpVyB'></ins><ul id='dpVyB'></ul><sub id='dpVyB'></sub></form><legend id='dpVyB'></legend><bdo id='dpVyB'><pre id='dpVyB'><center id='dpVyB'></center></pre></bdo></b><th id='dpVyB'></th></span></q></dt></tr></i><div id='dpVyB'><tfoot id='dpVyB'></tfoot><dl id='dpVyB'><fieldset id='dpVyB'></fieldset></dl></div>

        • <small id='dpVyB'></small><noframes id='dpVyB'>

              <bdo id='dpVyB'></bdo><ul id='dpVyB'></ul>

              <tfoot id='dpVyB'></tfoot>

                  <legend id='dpVyB'><style id='dpVyB'><dir id='dpVyB'><q id='dpVyB'></q></dir></style></legend>
                  本文介绍了标头如何与 PHP 中的输出缓冲一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  标题不言自明.

                  我对 PHP 有一些经验,但我不确定 header 函数在 ob_start()ob_end_clean() 之间是如何工作的代码>.

                  I have a good bit of experience with PHP, but I am not sure how the header function works between ob_start() and ob_end_clean().

                  考虑一下:

                  ob_start();
                  
                  echo "Some content";
                  header('X-Example-Header: foo');
                  echo "Some more content";
                  
                  $output = ob_get_contents();
                  ob_end_clean();
                  
                  echo $output;
                  

                  header 函数是否会忽略输出缓冲,因此所有标头都会在内容之前发送,因为它是在 header 之后 echoed打电话?

                  Does the header function ignore the output buffering, and thus all headers get sent before the content because it is echoed after the header call?

                  还是以其他方式起作用?

                  Or does it work some other way?

                  推荐答案

                  header() 确实忽略了输出缓冲.使用输出缓冲的部分原因是您可以乱序"发送 HTTP 标头,因为响应已被缓冲.一旦发送了任何类型的输出(除非该输出被缓冲),就不能发送 HTTP 标头.

                  The header() does indeed ignore output buffering. Part of the reason to use output buffering is so you can send HTTP headers "out of order" since the response is buffered. You can't send HTTP headers once you've sent any kind of output (unless that output is buffered).

                  这篇关于标头如何与 PHP 中的输出缓冲一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:标头后PHP会话被破坏/丢失 下一篇:如何确定压缩文件的内容长度?

                  相关文章

                  <tfoot id='DVgPk'></tfoot>

                    <bdo id='DVgPk'></bdo><ul id='DVgPk'></ul>

                  <i id='DVgPk'><tr id='DVgPk'><dt id='DVgPk'><q id='DVgPk'><span id='DVgPk'><b id='DVgPk'><form id='DVgPk'><ins id='DVgPk'></ins><ul id='DVgPk'></ul><sub id='DVgPk'></sub></form><legend id='DVgPk'></legend><bdo id='DVgPk'><pre id='DVgPk'><center id='DVgPk'></center></pre></bdo></b><th id='DVgPk'></th></span></q></dt></tr></i><div id='DVgPk'><tfoot id='DVgPk'></tfoot><dl id='DVgPk'><fieldset id='DVgPk'></fieldset></dl></div>

                    <small id='DVgPk'></small><noframes id='DVgPk'>

                    1. <legend id='DVgPk'><style id='DVgPk'><dir id='DVgPk'><q id='DVgPk'></q></dir></style></legend>