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>
答案 0 :(得分:0)
您正在寻找的是新的&#39;添加了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; ?>
(另请注意,这些内联回声不被视为良好的编码风格,但为了简单起见,我保留了它)
有关更多可能性(以及与旧浏览器的更多兼容性),请查看此问题并获得许多答案: How to make a progress bar