天天看點

如何在CLI指令行下運作PHP腳本,同時向PHP腳本傳遞參數?

<?php

/*

//指令行輸入輸出流

fwrite(stdout,"enter your name:");

$name =

trim(fgets(stdout));

fwrite(stdout,"hello,$name");

*/

echo

$argc;

if ($argc > 1){

print_r($argv);

}

?> 

 另存為 ./test.php

[root@xiuran test]# php  ./test.php xxx fdf

3array

(

    [0]

=> test.php

    [1] =>

xxx

    [2] =>

fdf

)