php ob_flush flush 輸出緩衝執行個體與說明_PHP教程

來源:互聯網
上載者:User
使用ob_flush()前,確保前面的內容大小足夠4069字元。一些Web伺服器的output_buffering預設是4069字元或者更大,即輸出內容必須達到4069字元伺服器才會flush重新整理輸出緩衝,為了確保flush有效

php教程 ob_flush flush 輸出緩衝執行個體與說明

*/
ob_flush();
//
flush();
//
function flush (){
echo(str_repeat(' ',256));
// check that buffer is actually set before flushing
if (ob_get_length()){
@ob_flush();
@flush();
@ob_end_flush();
}
@ob_start();
}


//str_repeat(string,repeat) 把字串重複指定的次數。


//執行個體二

@apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', 0);
@ini_set('implicit_flush', 1);
for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); }
ob_implicit_flush(1);


/*
使用注意事項:
flush和ob_flush的使用上有一些特別容易犯錯的地方,造成無法重新整理輸出緩衝。

一. flush和ob_flush的正確順序,正確應是,先ob_flush再flush,如下:

以下為引用的內容:

ob_flush();
flush();

如果web伺服器的作業系統是windows系統,那順序顛倒或者不使用ob_flush()也不會出現問題。但是在linux系統上就無法重新整理輸出緩衝。

二. 使用ob_flush()前,確保前面的內容大小足夠4069字元。
一些web伺服器的output_buffering預設是4069字元或者更大,即輸出內容必須達到4069字元伺服器才會flush重新整理輸出緩衝,為了確保flush有效


http://www.bkjia.com/PHPjc/445393.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445393.htmlTechArticle使用ob_flush()前,確保前面的內容大小足夠4069字元。一些Web伺服器的output_buffering預設是4069字元或者更大,即輸出內容必須達到4069字元伺服器...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.