WMWW | Webmaster Forumu | Webmaster Platformu
[PHP] File Size Calculator / Dosya Boyut Hesaplayıcı - Yazdırılabilir Sürüm

+- WMWW | Webmaster Forumu | Webmaster Platformu (https://wmwebworld.com/forum)
+-- Forum: Webmaster Dünyası (https://wmwebworld.com/forum/webmaster-dunyasi)
+--- Forum: Hazır Kodlar (https://wmwebworld.com/forum/hazir-kodlar)
+--- Konu: [PHP] File Size Calculator / Dosya Boyut Hesaplayıcı (/f-php-file-size-calculator-dosya-boyut-hesaplayici.html)



[PHP] File Size Calculator / Dosya Boyut Hesaplayıcı - oxcakmak - 08-05-2019

PHP Kod:
function calcSize($bytes){
    $fsize $bytes;
    switch ($bytes):
        case $bytes 1024:
            $fsize $bytes .' B'; break;
        case $bytes 1048576:
            $fsize round($bytes 10242) .' KB'; break;
        case $bytes 1073741824:
            $fsize round($bytes 10485762) . ' MB'; break;
        case $bytes 1099511627776:
            $fsize round($bytes 10737418242) . ' GB'; break;
    endswitch;
    return $fsize;



Kullanımı:
PHP Kod:
echo calcSize(filesize("path/to/text.txt"));