How to pass parameters from bash to php script?

Call it as:

php /path/to/script/script.php -- 'id=19&url=http://bkjbezjnkelnkz.com'

Also, modify your PHP script to use parse_str():

parse_str($argv[1]);

If the index $_SERVER['REMOTE_ADDR'] isn’t set.


More advanced handling may need getopt(), but parse_str() is a quick’n’dirty way to get it working.

Leave a Comment