服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - PHP教程 - PHP 进度条函数的简单实例

PHP 进度条函数的简单实例

2021-06-27 21:54用户昵称不能为空 PHP教程

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

php 进度条函数的简单实例

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

实例代码:

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

效果截图: 100%的时候。

PHP 进度条函数的简单实例

PHP 进度条函数的简单实例

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

原文链接:http://blog.csdn.net/default7/article/details/8395651

延伸 · 阅读

精彩推荐