Simple method of calculating bytes/kb/mb/tb/gb
<p>I have wanted to create a script like this for ages. I've attempted it below, for some reason nothing is display. Does someone else have any examples of a class such as this. What do you think is an efficient way to display this. This is based on the user entering a value. </p>

<pre><code>&lt;?php


    if($_GET['step'] == 2) {

    $bytes = $_GET['bytes'];

    echo $bytes; 

    $kilobyte = 1024;
$megabyte = $kilobyte * 1024;
$gigabyte = $megabyte * 1024;
$terabyte = $gigabyte * 1024;

if (($bytes &gt;= 0) &amp;&amp; ($bytes &lt; $kilobyte)) {
    return $bytes;

}
   if (($bytes &gt;= $kilobyte) &amp;&amp; ($bytes &lt; $megabyte))
    {
    return $kb = round($bytes / $kilobyte); 

}
     if (($bytes &gt;= $megabyte) &amp;&amp; ($bytes &lt; $gigabyte))
     {
    return $mb = round($bytes / $megabyte);
}
    if (($bytes &gt;= $gigabyte) &amp;&amp; ($bytes &lt; $terabyte))
    {
    return $gb = round($bytes / $gigabyte);

}
    if ($bytes &gt;= $terabyte)
    {
    return $tb = round($bytes / $terabyte);
}
    else {
    return $bytes;
}

    $content .= "&lt;h2&gt;Details of Memory Size &lt;/h2&gt;

    &lt;table&gt;

        &lt;tr&gt;
                            &lt;th&gt;Bytes&lt;/th&gt;
            &lt;th&gt;KB&lt;/th&gt;                 
            &lt;th&gt;MB&lt;/th&gt;
            &lt;th&gt;GB&lt;/th&gt;
                            &lt;th&gt;TB&lt;/th

        &lt;/tr&gt;";





            $content .= "&lt;tr &gt;
                    &lt;td&gt; $bytes&lt;/td&gt;
                                            &lt;td&gt;$kb &lt;/td&gt;
                                            &lt;td&gt;$mb&lt;/td&gt;
                                            &lt;td&gt;$gb&lt;/td&gt;
                                            &lt;td&gt;$tb&lt;/td&gt;

                                        &lt;/tr&gt;       
                                   ";




    }

   else {


   $content = " &lt;form action='index.php?step=2' method='post'&gt;
   &lt;table&gt;
   &lt;tr&gt;
   &lt;th&gt;Enter the number of kilobytes on unix drive&lt;/th&gt; 
   &lt;td&gt;&lt;input type='text' name='bytes'/&gt;&lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
   &lt;td&gt;
   &lt;input type='submit' /&gt;
   &lt;/td&gt;
   &lt;/table&gt;
   &lt;/form&gt;";

    echo $bytes; 
   }


 ?&gt;
</code></pre>
