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获取当前日期及本周一是几月几号的方法

本文实例讲述了PHP获取当前日期及本周一是几月几号的方法。分享给大家供大家参考,具体如下: <?php header("content-type:text/html...

php 无限极分类

复制代码 代码如下:<?php /*======================================================== 类名:catalog 功能:无...

php接口数据加密、解密、验证签名

代码很简单,这里就不多废话了,直接奉上代码 复制代码 代码如下: <?php //header('Content-Type: text/xml; charset=utf-8...

PHP中spl_autoload_register()函数用法实例详解

本文实例分析了PHP中spl_autoload_register()函数用法。分享给大家供大家参考,具体如下: 在了解这个函数之前先来看另一个函数:__autoload。 一、__aut...

PHP中动态显示签名和ip原理

<?php  //包含一个计数器,一个提醒语句,用户ip以及自己的广告图片。 //给浏览器发送头,说我是张图片 Header("Content-type: im...