PHP 进度条函数的简单实例

yipeiwu_com5年前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下实现在指定目录搜索指定类型文件的函数

复制代码 代码如下:function bdir($dir,$typearr){ $ndir = scandir($dir); foreach ($ndir as $k => $v)...

解析php获取字符串的编码格式的方法(函数)

如果不清楚字符串的编码格式的话,就可以将这段字符这样检查:$encode = mb_detect_encoding($string, array("ASCII",'UTF-8′,"GB2...

学习php设计模式 php实现观察者模式(Observer)

学习php设计模式 php实现观察者模式(Observer)

一、意图 定义对象间的一种一对多的依赖关系,当一个对象的状态发生改变时,所有依赖于它的对象都得到通知并被自动更新【GOF95】 又称为发布-订阅(Publish-Subscribe)模式...

PHP中的自动加载操作实现方法详解

本文实例讲述了PHP中的自动加载操作实现方法。分享给大家供大家参考,具体如下: what is 自动加载? 或许你已经对自动加载有所了解。简单描述一下:自动加载就是我们在new一个cla...

jq的get传参数在utf-8中乱码问题的解决php版

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//E...