是否可以从 PHP 获取特殊的本地磁盘信息?
我在本地计算机上运行我的PHP代码,所以,我只想知道PHP有什么函数来获取本地硬盘信息。例如磁盘名称,磁盘空间,可用空间等。
非常感谢!!
I am running my PHP code on my local computer,So ,I just want to know the PHP has any functions to get the local hard disk information.Such as the disk name , disk space,free space available .etc.
Thank you very much!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
内置函数:
如果您需要更多,可以通过
system()
。对于磁盘使用情况,您还可以在网上找到不同的片段,例如:
shell_exec()
。Builtins:
If you need more, you can access local commands via
system()
.For disk usage, you'll also find different snippets on the net, e.g. this:
shell_exec()
.此外,是的,可以检索此信息,因为您可以执行命令。还有一些 PHP 函数可以检索有关磁盘的信息,请查看以下链接:
然而,检索磁盘的名称需要使用命令来完成。我刚刚在 VirtualBox 中启动了 Windows,似乎以下内容可以工作:
Volumenaam 是荷兰语“Volumename”的意思。我只有荷兰语版本的 Windows,因此您必须检查实际的字符串是什么。
祝你好运。
In addition, yes, it is possible to retrieve this information, because you can execute commands. There are a few PHP functions to retrieve information about the disk as well, check out the following links:
Retrieving the disk's name, however, needs to be done with a command. I've just booted Windows in VirtualBox and it seems the following would work:
Volumenaam is Dutch for "Volumename". I only have the Dutch version of Windows, so you'd have to check what the actual string is.
Good luck.
有两个函数:
disk_free_space()
和disk_total_space()
。There are two functions:
disk_free_space()
anddisk_total_space()
.在您在这里提问之前,您是否尝试搜索过 PHP 手册?
这两个函数对我来说很快就出现了:
disk_total_space ()
disk_free_space ()
更多数据,例如光盘名称可能会更棘手(您可能需要按照此处的另一个答案使用
system()
),但这应该给您一个开始。但请注意,当 PHP 在网站中运行时,它的功能会受到相当多的限制;它可能仅限于其本地 Web 文件夹才能进行任何光盘访问。
Did you try searching the PHP manual before you asked here?
These two functions came up very quickly for me:
disk_total_space()
disk_free_space()
Further data such as the disc name may be trickier (you may need to use
system()
as per another answer here), but that should give you a start.However, note that when PHP is running in a web site, it will have quite a lot of restrictions on what it can do; it's likely to be restricted to its local web folders for any disc access.
对于磁盘名称,您可以使用此函数
For the Disk Name you can use this function