是否可以从PHP获取特殊的本地磁盘信息? [英] Is it possible to get special Local Disk information from 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.
非常感谢您!
推荐答案
此外,是的,由于您可以执行命令,因此可以检索此信息.还有一些PHP函数也可以检索有关磁盘的信息,请查看以下链接:
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:
- disk_total_space ($ directory);
- disk_free_space ($ directory);
- disk_total_space( $directory );
- disk_free_space( $directory );
但是,需要使用命令来获取磁盘名称.我刚刚在VirtualBox中启动了Windows,看来可以使用以下方法:
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:
if( preg_match( '~Volumenaam : (.*)~i', `fsutil fsinfo volumeinfo C:\\`, $matches ) ) {
echo $matches[1];
}
Volumenaam的荷兰语为"Volumename".我只有Windows的荷兰语版本,因此您必须检查实际的字符串是什么.
Volumenaam is Dutch for "Volumename". I only have the Dutch version of Windows, so you'd have to check what the actual string is.
祝你好运.
这篇关于是否可以从PHP获取特殊的本地磁盘信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!