Home > Backend Development > PHP Tutorial > Example analysis of progress bar function in php

Example analysis of progress bar function in php

黄舟
Release: 2023-03-16 09:44:01
Original
1469 people have browsed it

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 = &#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; 
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template