PHP 进度条函数的简单实例
其实进度条的做法很简单的。网上的一大堆,自己写了一个,哈哈,感觉看起来很有感觉。
实例代码:
01 | function ShowPercent( $now , $total ) |
03 | $percent = sprintf( '%.0f' , $now *100/ $total ); |
04 | $html = '<table width="60%" style="border-collapse:separate" height="10" border="0" cellpadding="0" cellspacing="2" bgcolor="#fff"><tr>' ; |
07 | while ( $count < $total ) |
09 | $bgcolor = $count < $now ? 'green' : '#EEEEEE' ; |
10 | $html .= '<td bgcolor="' . $bgcolor . '"> </td>' ; |
12 | if ( $count % $pertr == 0) $html .= '</tr><tr>' ; |
14 | $bgcolor2 = $now == $total ? ' style="font-weight:bold;color:green;"' : '' ; |
15 | $html .= '<td' . $bgcolor2 . ' colspan="' .( $count % $pertr ). '">' . $percent . '%</td></tr></table>' ; |
效果截图: 100%的时候。


如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!