如何将文本转换为进度条


how can I convert the text into a progress bar?

Hier ist das bild我想将文本转换为进度条,但不知道如何做到这一点。你能帮我吗?我尝试了很多东西。

我希望你能帮助我并理解我写的内容,谢谢。

 $df = disk_free_space("E:");
 $dt = disk_total_space("E:");
 $du = $dt - $df;
 $dp = sprintf('%.2f',($du / $dt) * 100);
 $df = formatSize($df);
 $du = formatSize($du);
 $dt = formatSize($dt);
 function formatSize( $bytes )
 {
     $types = array( 'B', 'KB', 'MB', 'GB', 'TB' );
     for( $i = 0; $bytes >= 1024 && $i < ( count( $types ) -1 ); $bytes /= 1024, $i++ );
     return( round( $bytes, 2 ) . " " . $types[$i] );
 }
 ?>
 <div class="pbl">
 <table class='ipb_table' cellspacing='1'>
     <tr>
         <td class='row2' colspan='2'>
             <div class='progress'>
                 <div class='prgbar'></div>
             </div>
         </td>
     <tr>
         <td class='row2'>
             Gesamter Speicher:
         </td>
         <td class='row2'>
             <?php echo "$dt"; ?>
         </td>
     </tr>
     <tr>
         <td class='row2'>
             Frei:
         </td>
         <td class='row2'>
             <?php echo "$df"; ?>
         </td>
     </tr>
     <tr>
         <td class='row2'>
             Gebraucht:
         </td>
         <td class='row2'>
             <?php echo "$du"; ?>
         </td>
     </tr>
     <tr>
         <td class='row2' colspan='2' align='center'>
             <a class='ipsButton' id='go'>Refresh<a>
         </td>
     </tr>
 </table>
 </div>

您要查找的是"新"添加的html元素<progress>。请注意,较旧的浏览器将无法呈现该元素。

在您的情况下,实现将是:

<progress value="<?php echo intval($du); ?>" max="<?php echo intval($dt); ?>">
   fallback text if the browser doesn't support progress-element
</progress><?php echo $dp; ?>

(另请注意,这些内联回显不被认为是好的编码风格,但为了简单起见,我保留了它)

有关更多的可能性(以及与旧浏览器的更多兼容性),请查看此问题,它有很多答案:如何制作进度条