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

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

相关文章

有关phpmailer的详细介绍及使用方法

第一,需要下载PHPMailer文件包phpmailer. http://phpmailer.sourceforge.net/第二,确认你的服务器系统已经支持socket ,通过phpi...

编写php应用程序实现摘要式身份验证的方法详解

通基本身份认证一样,也可以使用PHP网页处理HTTP请求报头字段来匹配摘要式身份验证信息。例如下边的代码使用header()函数要求客户端使用Digest验证,它在HTTP消息报头中增加...

请离开include_once和require_once

诚然, 这个理由是对的, 不过, 我今天要说的, 是另外一个的原因.我们知道, PHP去判断一个文件是否被加载, 是需要得到这个文件的opened_path的, 意思是说, 比如:复制代...

PHP中iconv函数知识汇总

今天在修改论文在线的时候,遇到了iconv这个函数。学习一下 header('Content-Type: application/vnd.ms-excel;charset=UTF-8...

解析PHP中empty is_null和isset的测试

代码如下:复制代码 代码如下:<?php$a;$b = false;$c = '';$d = 0;$e = null;$f = array();首先是empty的var_dump输...