How to pass parameters from bash to php script?

前端 未结 3 1792
失恋的感觉
失恋的感觉 2020-12-03 20:48

I have done a a bash script which run php script. It works fine without parameters but when I add parameters (id and url), there are some errors:

PHP Deprec         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-03 21:21

    You can't pass GET query parameters to the PHP command line interface. Either pass the arguments as standard command line arguments and use the $argc and $argv globals to read them, or (if you must use GET/POST parameters) call the script through curl/wget and pass the parameters that way – assuming you have the script accessible through a local web server.

    This is how you can pass arguments to be read by $argc and $argv (the -- indicates that all subsequent arguments should go to the script and not to the PHP interpreter binary):

    php myfile.php -- argument1 argument2

提交回复
热议问题