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 it. I hope it can help everyone.
Simple example 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.
Related recommendations:
jquery web page loading progress bar implementation method
How to display the HTML5 Ajax file upload progress bar
Ajax method to implement the loading progress bar
The above is the detailed content of A simple example of PHP progress bar function. For more information, please follow other related articles on the PHP Chinese website!