PHP检测(或删除)当前驱动器号? [英] PHP detect (or remove) current drive letter?
问题描述
我正在尝试为PHP寻找一种方法来检测我的应用程序所在的USB的驱动器号,但是我没有任何运气.
I'm trying to find a way for PHP to detect the drive letter of the USB my app is on, but I'm not having any luck.
我正在制作一个与我从Portableapps.com安装的应用程序并驾齐驱的桌面.主桌面和所有应用程序都在USB驱动器上; PHP文件存储在USB版本的xampp中.
I'm making a desktop which goes hand in hand with the apps I installed from portableapps.com. The main desktop and all the apps are on a USB drive; the PHP files are stored in the USB version of xampp.
当前,我有一个条件语句,如果我要单击其中一个便携式应用程序的桌面图标,它将附加?app = APPNAME",然后由条件语句拾取并打开该应用程序.
Currently I have a conditional statement set up where if I was to click a desktop icon for one of the portable apps, it would append "?app=APPNAME" which would then be picked up by the conditional and open the app.
<?php
$app = $_GET['app'];
if ($app == 'pidgin') {
$addr = "E:/PortableApps/PidginPortable/PidginPortable.exe";
exec ($addr,$output, $return);
}
?>
我希望能够将此驱动器插入任何计算机,而不会在打开应用程序时遇到问题,所以有没有办法删除文件位置中的E:/并仍然将其打开,或者至少有一种方法检测USB使用的驱动器号,并根据检测到的内容更改我的代码部分?
I want to be able to plug this drive into any computer and not run into problems opening the apps, so is there a way to remove the E:/ in the file location and still have them open or at least a way to detect what drive letter the USB is using and change that part of my code based on what it detects?
推荐答案
You may be able to parse it from the __FILE__
magic constant. I don't have any Windows computer, but I guess it will be the first character. So this may work:
$drive = substr(__FILE__, 0, 1);
这篇关于PHP检测(或删除)当前驱动器号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!