如何将变量从php传递到bat文件并读取其结果? [英] How to pass variable from php to bat file and read its result?
问题描述
如何将变量从php传递到bat文件并获取结果.我尝试如下
How to pass variable from php to bat file and get back the result. I tried as follows
<?php
$input="layer";
echo shell_exec("F:\xampp\htdocs\flood_publish\123.bat",$input)
?>
以及如何在bat文件中访问和使用该变量.
and how to access and use that variable in bat file..
推荐答案
您可以将变量作为参数传递到bat文件,并且示例中的"$ input"变量包含bat文件的输出.因此,如果要将变量传递到bat文件并将输出返回到php,则应编写如下内容:
You can pass variables to bat files as arguments and the "$input" variable from your example contains the output of the bat file. So, if you want to pass a variable to a bat file and get the output back to the php, you should write something like this:
$input="layer";
exec("F:\xampp\htdocs\flood_publish\123.bat $input",$output);
print_r($output);
在这里您可以找到有关如何在.bat文件中使用参数的更多信息: 获取Windows批处理脚本(.bat )
Here you can find more about how to use arguments in .bat files: Get list of passed arguments in Windows batch script (.bat)
这篇关于如何将变量从php传递到bat文件并读取其结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!