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中的加密方式有如下几种 1. MD5加密 string md5 ( string $str [, bool $raw_output = false ] ) 参数 str ...

PHP基于php_imagick_st-Q8.dll实现JPG合成GIF图片的方法

一、概述: 本文详解了PHP基于php_imagick_st-Q8.dll实现JPG合成GIF图片的方法。 首先要实现PHP使用php_imagick_st-Q8.dll类库,把JPG图...

php中调用其他系统http接口的方法说明

使用函数:  file_get_contents($url); 传入接口url及其参数:如 $url="http://192.168.1.1/test.jsp?id=1&typ...

PHP易混淆函数的区别及用法汇总

本文实例分析了PHP易混淆函数的区别及用法。分享给大家供大家参考。具体分析如下: 1.echo和print的区别 PHP中echo和print的功能基本相同(输出),但是两者之间还是有细...

完美解决thinkphp唯一索引重复时出错的问题

完美解决thinkphp唯一索引重复时出错的问题

比如如下字段(g_check_id):唯一索引 如果插入数据时(g_check_id)出现相同的值的话,程序本身是会报错的。 所以做类似如下处理: 以上这篇完美解决thinkphp...