PDA

View Full Version : PHP arguments from the command line


bauhsoj
07-21-2006, 09:20 PM
I read somewhere a while back that arguments can be sent to a PHP 5 script through a cronjob via $_REQUEST in some format. I know that I could send them through 'argv' but what if the server configuration does not have "register_argc_argv" set? How would I setup the arguments on the command line to send them in with a key/value pairing that shows up in $_REQUEST?

For instance, what would be the command line equivalent of the following?/some_script.php?do_something=yes&something_else=no

firepages
07-22-2006, 02:19 AM
as far as I am aware $_SERVER['argc'] & $_SERVER['argv'] will be available regardless of that setting... if thats not the case , you can specify the path to an alternate php.ini in the crontab...

php -q -c /usr/local/my_php.ini -f /home/user/script.php arg1 arg2 arg3

etc

bauhsoj
07-25-2006, 09:22 PM
Apparently simply adding "do_something=yes" and then checking $_REQUEST['something'] works fine for passing values to through the command line without any special parsing requirements.
php /path/to/script/some_script.php do_something=yes