Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass query string parameters to the PHP binary?

I am developing a webserver that invokes the PHP binary (via CGI) to process a script.

Here's the problem:

The PHP script isn't picking up the command line parameters. For example, if the client requests path/to/file.php?test=value, the $_GET array is empty.

I have tried passing the parameters in an environment variable (QUERY_STRING), but they still don't show up.

How can I pass query string parameters to a PHP application?

like image 918
Nathan Osman Avatar asked Oct 03 '10 06:10

Nathan Osman


1 Answers

There are various SAPIs for PHP. One of them is cli SAPI which apparently is what you're using, cli SAPI wouldn't populate $_GET, $_POST ... because it's for command line scripting.

In your case you need PHP cgi SAPI. (e.g., You need to replace php with php-cgi[1] in your shebang)

[1] In most distribuitons it's called php-cgi, if you compile PHP yourself you need to enable cgi.

like image 74
racetrack Avatar answered Nov 02 '22 22:11

racetrack