php 输出到textarea 滚动条自动向下移动<?php
class runtime
{
var $StartTime = 0;
var $StopTime = 0;
function get_microtime()
{
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}
function start()
{
$this->StartTime = $this->get_microtime();
}
function stop()
{
$this->StopTime = $this->get_microtime();
}
function spent()
{
return round(($this->StopTime - $this->StartTime) * 1000, 1);
}
}
$runtime= new runtime;
echo '
<textarea rows= "5 " cols= "20 " id= "ScrollText ">
';
set_time_limit(0);
ob_end_flush();
for($i = 0; $i<100000; $i++){
$runtime->start();
sleep(1);
//usleep(1000000);
echo $i."\n";
flush();
$runtime->stop();
echo "执行时间: ".$runtime->spent()." 毫秒\n";
}echo '</textarea>';
?>
$runtime->start();
echo $i."\n"; flush();
ob_flush();
usleep(250000);
$runtime->stop();
echo "执行时间: ".$runtime->spent()." 毫秒\n";
}
ob_end_flush();