这篇文章主要介绍了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中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号