代码之家  ›  专栏  ›  技术社区  ›  Mark Lalor

PHP系统批处理参数

  •  1
  • Mark Lalor  · 技术社区  · 15 年前

    使用 PHP的 system 功能,你怎么能 向批处理文件传递参数?

    可能看起来像这样

    system("batch.bat argument", $output);

    C++可执行文件 here

    我猜应该比较简单。。。

    真正的问题是如何用批处理文件接收参数?

    2 回复  |  直到 9 年前
        1
  •  4
  •   codaddict    15 年前

    你说得对,没有区别。下面是一个小演示:

    首先创建一个批处理文件,以便只输出其参数:

    C:\Documents and Settings\SO>type a.bat
    @echo off
    echo %*
    

    使用 system 调用批处理文件传递 a b 作为参数:

    C:\Documents and Settings\SO>type a.php
    <?php
        system("a.bat a b",$out);
    ?>
    

    系统 调用bat文件 b 批处理文件作为参数运行并回显 b

    C:\Documents and Settings\SO>php a.php
    a b
    
    推荐文章