-2
我想創建一個這樣的腳本很長時間。我在下面試過,由於某種原因沒有顯示。其他人是否有類似這樣的例子。你認爲什麼是一種有效的方式來顯示這一點。這是基於用戶輸入一個值。計算字節/ kb/mb/tb/gb的簡單方法
<?php
if($_GET['step'] == 2) {
$bytes = $_GET['bytes'];
echo $bytes;
$kilobyte = 1024;
$megabyte = $kilobyte * 1024;
$gigabyte = $megabyte * 1024;
$terabyte = $gigabyte * 1024;
if (($bytes >= 0) && ($bytes < $kilobyte)) {
return $bytes;
}
if (($bytes >= $kilobyte) && ($bytes < $megabyte))
{
return $kb = round($bytes/$kilobyte);
}
if (($bytes >= $megabyte) && ($bytes < $gigabyte))
{
return $mb = round($bytes/$megabyte);
}
if (($bytes >= $gigabyte) && ($bytes < $terabyte))
{
return $gb = round($bytes/$gigabyte);
}
if ($bytes >= $terabyte)
{
return $tb = round($bytes/$terabyte);
}
else {
return $bytes;
}
$content .= "<h2>Details of Memory Size </h2>
<table>
<tr>
<th>Bytes</th>
<th>KB</th>
<th>MB</th>
<th>GB</th>
<th>TB</th
</tr>";
$content .= "<tr >
<td> $bytes</td>
<td>$kb </td>
<td>$mb</td>
<td>$gb</td>
<td>$tb</td>
</tr>
";
}
else {
$content = " <form action='index.php?step=2' method='post'>
<table>
<tr>
<th>Enter the number of kilobytes on unix drive</th>
<td><input type='text' name='bytes'/></td>
</tr>
<tr>
<td>
<input type='submit' />
</td>
</table>
</form>";
echo $bytes;
}
?>
你爲什麼要在那裏使用?你有沒有向我們展示什麼? –