PHP 进度条函数的简单实例

yipeiwu_com5年前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使用CURL实现多线程抓取网页

PHP 利用 Curl Functions 可以完成各种传送文件操作,比如模拟浏览器发送GET,POST请求等等,受限于php语言本身不支持多线程,所以开发爬虫程序效率并不高,这时候往往...

php采用curl访问域名返回405 method not allowed提示的解决方法

/** * http测试 * 注:PHP版本5.2以上才支持CURL_IPRESOLVE_V4 * @param $url 网站域名 * @param $type 网站访问协...

PHP7安装Redis扩展教程【Linux与Windows平台】

本文实例讲述了PHP7安装Redis扩展的方法。分享给大家供大家参考,具体如下: linux中PHP7安装Redis扩展 1.依次执行 wget -c https://github....

ob_start(),ob_start('ob_gzhandler')使用

输出前使用尽量使用 ob_start();可以加快输出速度,适用NT 对unix类服务器 如果使用ob_start('ob_gzhandler');输出效率将更高...

Memcached常用命令以及使用说明详解

Memcached常用命令以及使用说明详解

存储命令的格式:<command name> <key> <flags> <exptime> <bytes><data...