Home  >  Article  >  Backend Development  >  TP_PHP及时显示执行数据

TP_PHP及时显示执行数据

WBOY
WBOYOriginal
2016-06-23 13:34:19910browse

控制器方法

    public function autoDemo(){        $this->display();        for ($i=0; $i < 50; $i++) {             sleep(3);            show_msg($i.'*3秒过去了...','green');        }   }

输出函数

function show_msg($msg, $class = ''){    echo "<script type=\"text/javascript\">showmsg(\"{$msg}\", \"{$class}\")</script>";    flush();    ob_flush();}

模板

<!DOCTYPE html><html><head>	<meta charset="UTF-8">	<title>Document</title></head><body>    <div id="show-list" class="install-database">    </div>    <script type="text/javascript">        var list   = document.getElementById('show-list');        function showmsg(msg, classname){            var li = document.createElement('p');             li.innerHTML = msg;            classname && li.setAttribute('class', classname);            list.appendChild(li);            document.scrollTop += 30;        }    </script></body></html>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn