PHP磁盘总空间
我需要有关 disk_total_space 函数的帮助..
我的代码中有这个
<?php
$sql="select * from users order by id";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)) {
?>
Name : <?php echo $row['name']; ?>
Email : <?php echo $row['email']; ?>
Diskspace Available : <?php
$dir = "C:/xampp/htdocs/freehosting/".$row['name'];
disk_total_space($dir);
} ?>
但是这会为每个用户返回相同的磁盘空间..
任何人都可以告诉我一些信息吗?
谢谢 :)
i need help with disk_total_space function..
i have this on my code
<?php
$sql="select * from users order by id";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)) {
?>
Name : <?php echo $row['name']; ?>
Email : <?php echo $row['email']; ?>
Diskspace Available : <?php
$dir = "C:/xampp/htdocs/freehosting/".$row['name'];
disk_total_space($dir);
} ?>
However this return me same disk space for every users ..
Anyone can shed me some light?
thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
https://www.php.net/disk_total_space 说,
您可能会看到 C 的 Total_space:
两者都存在替代解决方案Windows 和 Linux。
https://www.php.net/disk_total_space says,
You're likely seeing the total_space of C:
Alternative solutions do exist for both Windows and Linux.
我认为你想要的是这样的:
编辑:递归函数最初有一个错误。 现在它还应该读取原始文件夹中的文件夹以及这些文件夹中的文件夹,依此类推。
I think what you want is something like this:
edit: the recursive function had a bug in it originally. Now it should also read folders inside the original folders, and folders inside those folders, and so on.
我认为该方法只会告诉您有关给定目录所在的文件系统或分区的信息。 您可以尝试简单地使用 du :
-s 总结整个目录, -h 以“人类”单位(例如 MB 和 GB)返回结果。
编辑:抱歉,我错过了这是在 WIndows 上进行的。 我会留下答案,以防它帮助搜索类似问题的人。 对于 Windows,尝试 PHP 手册中的此建议
I think that method will only tell you information about the filesystem or partition the given directory is on. You could try simply shelling out to du though:
-s summarizes the entire dir, -h returns the result in "human" units like MB and GB.
Edit: apologies, I missed that this was on WIndows. WIll leave the answer in case it helps someone searching for a similar problem. For windows, try this suggestion in the PHP manual
PHP.net 上该函数的注释似乎表明,这给出了
$dir
所在的驱动器/分区的空间,而不是$dir
本身的大小。The comments on the function on PHP.net appear to indicate that this gives the space of the drive/partition
$dir
is in, not the size of$dir
itself.根据
disk_total_space()
的文档,返回的值是目录所在的文件系统。 它不计算目录及其子目录中使用的空间。您可以使用
du
或寻求更便携的解决方案:According to the docs for
disk_total_space()
, the value returned is for the filesystem the directory is located on. It doesn't count the space used in a directory + its subdirectories.You could shell out to
du
or for a more portable solution:您可以使用该功能:
You could use the function: