Re: Division Problems

From: Date: Wed, 04 Jul 2001 17:48:19 +0000
Subject: Re: Division Problems
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-56207@lists.php.net to get a copy of this message
Found it, I had it returning mbyte not mbytes....arrrg ----- Original Message ----- From: ReDucTor <sjdtmv@tpg.com.au> To: <php-general@lists.php.net> Sent: Thursday, July 05, 2001 3:43 AM Subject: [PHP] Division Problems Hey, I made this little script, quiet useful on windows and unix machines, but i have a problem, division isn't returning a float, it just returns 0, would i need to do something like convert $totalsize into a float? <html> <body><?php $SecondsToTimeout = 120; ini_alter(max_execution_time, $SecondsToTimeout); function convert($bytes) { $kbytes = $bytes / 1024; $mbytes = $kbytes / 1024; $gbytes = $mbytes / 1024; $tbytes = $gbytes / 1024; return $mbyte; } function showdir($dir) { echo "<blockquote>"; $handle = opendir($dir); while (false!==($file = readdir($handle))) if ($file != "." && $file != "..") if(is_file($dir."/".$file)){ // Commented out for fixing this error // echo $file." (<i>".filesize($dir."/".$file)." Bytes</i>)(<i>".filetype($dir."/".$file)."</i>)(<i>".fileperms($dir."/".$fil e)."</i>)<br>\n"; } if(is_dir($dir."/".$file)){ $dirhandle = opendir($dir."/".$file); while(false!==($filetocheck=readdir($dirhandle))){ if(!isset($totalsize)) $totalsize = filesize($dir."/".$file."/".$filetocheck); else $totalsize = $totalsize + filesize($dir."/".$file."/".$filetocheck); } echo $file." (<i>".convert($totalsize)."</i>)<br>\n"; showdir($dir.".".$file); // Put / on unix, and c:/ on windows } } } echo "</blockquote>"; } showdir("/"); ini_restore(max_execution_time); ?></body></html>

« previous php.general (#56207) next »