How to pass parameters from command line to $_POST in php-script?
问题 I know this could sound a little weird but I need to pass some parameters to a $_POST array. Similar to the way apache does it, or any other web server. Unfortunately I couldn't find libapache2-mod-php5 anywhere for my Ubuntu. 回答1: That's not easily doable. You can invoke the php-cgi binary and pipe a fake POST request in. But you'll need to set up a whole lot of CGI environment variables: echo 'var1=123&var2=abc' | REQUEST_METHOD=POST SCRIPT_FILENAME=script.php REDIRECT_STATUS=CGI CONTENT