PHP在程序处理过程中动态输出内容
生活随笔
收集整理的這篇文章主要介紹了
PHP在程序处理过程中动态输出内容
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在安裝discuz或其他一些開源產品的時候,在安裝數據庫時頁面上的安裝信息都是動態輸出出來的,主要通過php兩個函數來實現的,
flush();ob_flush();
代碼如下
<html xmlns="http://www.w3.org/1999/xhtml"><head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <title>Discuz! 安裝向導</title> <style type="text/css"> body{ padding:5px 0; background:#FFF; text-align:center; } body, td, input, textarea, select, button{ color:#666; font:12px/1.5 Verdana, Tahoma, Arial, 'Microsoft Yahei', 'Simsun', sans-serif; } .container{ overflow:hidden; margin:0 auto; width:700px; height:auto !important;text-align:left; border:1px solid #B5CFD9; } .main{ padding:20px 20px 0; background:#F7FBFE url(bg_repx.gif) repeat-x 0 -194px; }.main h3{ margin:10px auto; width:75%; color:#6CA1B4; font-weight:700; } #notice { overflow: hidden; margin: 20px; padding: 5px; height: 300px; border: 1px solid #B5CFD9; text-align: left; } </style> <meta name="Copyright" content="Comsenz Inc."> </head> <body><div> <div><script type="text/javascript"> function showmessage(message) {document.getElementById('notice').innerHTML += message + '<br/>';document.getElementById('notice').scrollTop = 100000000; } </script><div id="notice"></div> <?php //檢測完成后顯示的信息 function showjsmessage($message) {echo '<script type="text/javascript">showmessage(\''.addslashes($message).' \');</script>'."\r\n";flush();ob_flush(); }//模擬初始化數據表 for ($i = 1; $i <= 50; $i++) {showjsmessage("建立數據表 {$i} ... 成功");sleep(rand(0, 1)); }?> </div> </div> </body> </html>測試的結果是,在apache下是可以的,在Nginx下不行。
轉載于:https://www.cnblogs.com/zhucheer/p/4064349.html
總結
以上是生活随笔為你收集整理的PHP在程序处理过程中动态输出内容的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 关系数据库的几种设计范式介绍
- 下一篇: 标准错误处理机制——error