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

TP_PHP及时显示执行数据

WBOY
Release: 2016-06-23 13:34:19
Original
951 people have browsed it

控制器方法

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

输出函数

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

模板

<!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>
Copy after login


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template