PHP 进度条函数的简单实例

yipeiwu_com6年前PHP代码库

PHP 进度条函数的简单实例

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

实例代码:

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使用strip_tags()去除html标签仍有空白的解决方法

本文实例讲述了php使用strip_tags()去除html标签仍有空白的解决方法。分享给大家供大家参考,具体如下: $subject = strip_tags($newsRs['c...

php实现遍历文件夹的方法汇总

php 遍历 文件夹 ,不少时候还是很需要的 /*获取所有文件*/ function get_all_files( $path ){ $list = array(); for...

PHP7内核CGI与FastCGI详解

PHP7内核CGI与FastCGI详解

CGI:是 Web Server 与 Web Application 之间数据交换的一种协议。 FastCGI:同 CGI,是一种通信协议,但比 CGI 在效率上做了一些优化。 PHP-...

thinkphp 字母函数详解T/I/N/D/M/A/R/U

1、 /** * 获取模版文件 格式 资源://模块@主题/控制器/操作 * @param string $template 模版资源地址 * @param string $l...

php 静态变量的初始化

例如: class A { public $f1 = 'xxxx'; static public $f2 = 100; } 如果要将变量赋值为对象,那么只能在构造器中进行初始化,例如:...