PHP CLI with parameters
October 21, 2008
For a current project, I needed a (PHP) CLI script that had to accept a certain parameter list. Using CLI, you can do:
php /path/to/script/script.php arg1 arg2 arg3
I retrieve the parameters in the script by using the $_SERVER[‘argv’] array:
$param1 = $_SERVER[‘argv’][0];
$param2 = $_SERVER[‘argv’][1];
I kinda feel dirty using the $_SERVER[‘argv’] variable. Any decent method to do this?
October 22, 2008 at 3:35 pm
getopt ?