首頁 >後端開發 >php教程 >php中關於進度條函數的實例分析

php中關於進度條函數的實例分析

黄舟
黄舟原創
2017-09-20 09:25:391494瀏覽

這篇文章主要介紹了PHP 進度條函數的簡單實例的相關資料,希望透過本文能幫助到大家,需要的朋友可以參考下

PHP 進度條函數的簡單實例

其實進度條的做法很簡單的。網路上的一大堆,自己寫了一個,哈哈,感覺看起來很有感覺。

實例程式碼:


function ShowPercent($now,$total) 
{ 
 $percent = sprintf('%.0f',$now*100/$total); 
 $html = &#39;<table width="60%" style="border-collapse:separate" height="10" border="0" cellpadding="0" cellspacing="2" bgcolor="#fff"><tr>&#39;; 
 $count=0; 
 $pertr = 30; 
 while($count < $total) 
 { 
  $bgcolor = $count < $now ? &#39;green&#39;:&#39;#EEEEEE&#39;; 
  $html .= &#39;<td bgcolor="&#39;.$bgcolor.&#39;"> </td>&#39;; 
  $count++; 
  if($count%$pertr == 0) $html .= &#39;</tr><tr>&#39;; 
 } 
 $bgcolor2 = $now == $total ? &#39; style="font-weight:bold;color:green;"&#39;:&#39;&#39;; 
 $html .= &#39;<td&#39;.$bgcolor2.&#39; colspan="&#39;.($count%$pertr).&#39;">&#39;.$percent.&#39;%</td></tr></table>&#39;; 
 return $html; 
}

效果截圖: 100%的時候。

以上是php中關於進度條函數的實例分析的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn