Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not understanding working filesize() function

Tags:

php

$path = "/////////.";

echo filesize( $path );

result is 4096

What the ... fail is this? from whence is this 4096 ?

like image 359
Oto Shavadze Avatar asked Sep 06 '26 08:09

Oto Shavadze


1 Answers

Answer:

$path = "/////////.";

although looking weird, the path refers to the root of the filesystem, the same as /, what is a directory. On most filesystems a directory takes at least 4096 bytes to store (what is the size of one sector of a harddisk, the smallest allocation unit for most filesystems). The size can be even bigger if there are many files stored in that directory. But in the system root there are usually only the standard system directories, therefore just 4096.

like image 67
hek2mgl Avatar answered Sep 07 '26 21:09

hek2mgl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!