PHP command line accept inputs – $argv


~a sudo php scriptname.php 100

pass IN 100 to the script.

In the script, receive input:

$batchNumber = $argv[1]

test it:


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.