php cli传递参数的方法

来源:互联网 发布:华为预装软件卸载 编辑:程序博客网 时间:2024/05/23 05:09
php cli传递参数的方法
$options = "f:g:";    $opts = getopt( $options );    print_r($opts);  
在命令行下运行 /usr/local/php/bin/php ./getopt.php -f 123 -g 456
Array    (    [f] => 123    [g] => 456    )  
还有中方式像C语言
fwrite(STDOUT, "Enter your name: ");    $name = trim(fgets(STDIN));    fwrite(STDOUT, "Hello, $name!");   
在命令行下运行 /usr/local/php/bin/php ./getopt.phpEnter your name: zhang //(zhang 为用户输入) Hello, zhang!

查看原文:http://newmiracle.cn/?p=1804