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%的時候。
如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
【網站聲明】本站除付費源碼經過測試外,其他素材未做測試,不保證完整性,網站上部分源碼僅限學習交流,請勿用于商業用途。如損害你的權益請聯系客服QQ:2655101040 給予處理,謝謝支持。