导读进度条是很普遍的功能,我们在访问页面的时候都会显示,本文是爱站技术频道小编带来的PHP 进度条函数的简单实例,希望能对你学习这方面知识有所帮助。PHP 进度条函数的简单实例实例代码:function ShowPercent($now,

进度条是很普遍的功能,我们在访问页面的时候都会显示,本文是爱站技术频道小编带来的PHP 进度条函数的简单实例,希望能对你学习这方面知识有所帮助。

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 进度条函数的简单实例,相关的操作实例,在js.aizhan.com为大家继续展现。


原文链接:https://js.aizhan.com/develop/php/11554.html
如有疑问请与原作者联系