cli下经常会给脚本传递参数,php中用来接收参数的变量
function main($argc, $argv) {
printf(“params error, argc=%s, argv=%s”, $argc, print_r($argv, true));
}
main($argc,$argv);
==============================
output:
$ php test.php 2 `date +”%Y-%m-%d” -d “-1 days”`
params error, argc=3, argv=Array
(
[0] => test.php
[1] => 2
[2] => 2016-02-25
)