duanpengya7074 2010-09-04 17:03
浏览 46
已采纳

PHP系统批处理args

Using PHP's system function, how can you pass arguments to a batch file?

It would probably look something like this

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

I found out how to do it with a C++ executable here

I'm guessing it should be relatively simple...

What the real question is is how to receive the argument with a batch file?

  • 写回答

2条回答 默认 最新

  • dongzhuanlei0768 2010-09-04 17:11
    关注

    You are right, there is no difference. Here is a small demo:

    First a batch file to just output its arguments:

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

    A php program that uses system to invoke the batch file passing a and b as args:

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

    On running the php, the call to system invokes the bat file with a and b as arguments, the batch file runs and echoes a and b

    C:\Documents and Settings\SO>php a.php
    a b
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?