# php7下的filesize

```
echo round(filesize(basename(\$path))/1024,2).'KB';

```

```
echo filesize(basename(\$path)).'B'; //结果是正确文件字节大小。

```

```
\$path = 'c:\www\htdocs\index.php';
\$path2 = 'c:\www\htdocs\index.html';
echo filesize(basename(\$path)).'B'; //结果是正确文件字节大小。
echo '------';
echo round(filesize(basename(\$path2))/1024,2).'KB'; //结果是KB大小。

```

```
\$path = 'c:\www\htdocs\index.php';
\$path2 = 'c:\www\htdocs\index.html';
echo filesize(basename(\$path));  //精确后的大小
echo '----';
echo filesize(basename(\$path2)); //未精确大小

```
This entry was posted in php and tagged , , , , , . Bookmark the permalink.