ob_flush(); flush(); 1-100显示

来源:互联网 发布:淘宝女装美工 编辑:程序博客网 时间:2024/06/16 15:37
<div id="notice"></div>  
<script type="text/javascript">  
function shownum(width) {  
    document.getElementById('notice').innerHTML = '<p>' + width + '</p>';  
}  
</script>  
  
<?php  
    function showjsmessage($width)  
    {  
        echo '<script type="text/javascript">shownum(\'' . $width . '\');</script>';  
        // echo $width;//这样是不行的
        ob_flush();  
        flush();  
    }  




    $totalnum = 100;  
    for ($i = 1; $i <= $totalnum; $i++) {  
        $width = $i/$totalnum * 100;  
        showjsmessage($width);  
        usleep(10000);  
    }  
?>