导航首页 » 技术教程 » PHP 进度条函数的简单实例
PHP 进度条函数的简单实例 138 2023-12-08   

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%的时候。

查看图片

查看图片

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


!!!站长长期在线接!!!

网站、小程序:定制开发/二次开发/仿制开发等

各种疑难杂症解决/定制接口/定制采集等

站长微信:lxwl520520

站长QQ:1737366103