Home >Backend Development >PHP Tutorial >Example analysis of progress bar function in php
This article mainly introduces relevant information about simple examples of PHP progress bar function. I hope this article can help everyone. Friends in need can refer to
Simple examples of PHP progress bar function
In fact, the progress bar is very simple. There are a lot of them on the Internet, so I wrote one myself, haha, I think it looks very interesting.
Instance code:
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; }
Effect screenshot: 100% of the time.
The above is the detailed content of Example analysis of progress bar function in php. For more information, please follow other related articles on the PHP Chinese website!