当前位置:Gxlcms > PHP教程 > 关于PHP进度条函数的简单实例

关于PHP进度条函数的简单实例

时间:2021-07-01 10:21:17 帮助过:5人阅读

本文主要介绍了PHP 进度条函数的简单实例的相关资料,希望通过本文能帮助到大家,需要的朋友可以参考下,希望能帮助到大家。

PHP 进度条函数的简单实例

其实进度条的做法很简单的。网上的一大堆,自己写了一个,哈哈,感觉看起来很有感觉。

实例代码:


  1. function ShowPercent($now,$total)
  2. {
  3. $percent = sprintf('%.0f',$now*100/$total);
  4. $html = '<table width="60%" style="border-collapse:separate" height="10" border="0" cellpadding="0" cellspacing="2" bgcolor="#fff"><tr>';
  5. $count=0;
  6. $pertr = 30;
  7. while($count < $total)
  8. {
  9. $bgcolor = $count < $now ? 'green':'#EEEEEE';
  10. $html .= '<td bgcolor="'.$bgcolor.'"> </td>';
  11. $count++;
  12. if($count%$pertr == 0) $html .= '</tr><tr>';
  13. }
  14. $bgcolor2 = $now == $total ? ' style="font-weight:bold;color:green;"':'';
  15. $html .= '<td'.$bgcolor2.' colspan="'.($count%$pertr).'">'.$percent.'%</td></tr></table>';
  16. return $html;
  17. }

效果截图: 100%的时候。

相关推荐:

jquery网页加载进度条实现方法

HTML5 Ajax文件上传进度条如何显示

Ajax 实现加载进度条的方法

以上就是关于PHP 进度条函数的简单实例的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行