PHP command line accept inputs – $argv

http://php.net/manual/en/reserved.variables.argv.php

example:

~a sudo php scriptname.php 100

pass IN 100 to the script.

In the script, receive input:

$batchNumber = $argv[1]

test it:

var_dump($argv);

handy when calling a php script via a cron, thus allowing the script parameters to be configurable via the cron.

Leave a Reply

You must be logged in to post a comment.