[英]PHP exec() not running .exe unless both in same directory in XAMPP
I'm trying to using PHP to execute an .exe on my testing XAMPP server. 我正在尝试使用PHP在测试的XAMPP服务器上执行.exe。 However I can't seem to get an output from exec unless the .exe is in the same folder as the PHP file.
但是,除非.exe与PHP文件位于同一文件夹中,否则我似乎无法从exec获得输出。 PHP is located in /xampp/htdocs/mapping and I want to put the exe in /xampp/cgi-bin
PHP位于/ xampp / htdocs / mapping中,我想将exe放在/ xampp / cgi-bin中
<html>
<body>
<?php
exec("c:\xampp\cgi-bin\hello.exe", $output1);
exec("/cygdrive/c/xampp/cgi-bin/hello.exe", $output2);
exec("hello.exe", $output3);
print_r($output1);
print_r($output2);
print_r($output3);
?>
</body>
</html>
The output is this 输出是这个
Array ( ) Array ( ) Array ( [0] => Hello World! )
I think your PHP is running in "safe mode": 我认为您的PHP在“安全模式”下运行:
Note: When safe mode is enabled, you can only execute files within the safe_mode_exec_dir.
注意:启用安全模式后,您只能在safe_mode_exec_dir中执行文件。 For practical reasons, it is currently not allowed to have .. components in the path to the executable.
出于实际原因,当前不允许在可执行文件的路径中包含..组件。
See: 看到:
http://www.php.net/manual/en/function.exec.php http://www.php.net/manual/zh/function.exec.php
More info on safe mode: 有关安全模式的更多信息:
http://www.php.net/manual/en/features.safe-mode.php http://www.php.net/manual/zh/features.safe-mode.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.