_GET/_POST vars passed to PHP how?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Are these passed by the webserver to PHP using
commandline arguments or by environment variable?

Just curious.

If environment variables, which ones?


Re: _GET/_POST vars passed to PHP how?

Quoted text here. Click to load it

If PHP is run as an Apache module, it's done via some kind of
internal interface, and unless you're writing your own modules,
you shouldn't need to care.

If PHP is run as a CGI, it's done by the interface defined by CGI:
GET variables show up in environment variables (the CGI has to
separate them), and PUT variables are available on stdin (again,
the CGI has to separate them).  Environment variables indicate
whether this is GET or PUT and how much input is available on

If PHP is run from the command line, the variables are generally
not passed at all, and there may be no web server involved at all.

                    Gordon L. Burditt

Re: _GET/_POST vars passed to PHP how?

Gordon Burditt wrote:

Quoted text here. Click to load it

As an experiment I wrote a simple C program that invokes
PHP, but I'm getting an error "No input file specified.".

What I do is:

setenv ("REQUEST_METHOD", "GET", 1);
setenv ("QUERY_STRING", "abc=123", 1);

and then I invoke PHP thus:

system "/usr/local/bin/php myfile.php < dummyfile > foo";

and I also tried:

system "/usr/local/bin/php myfile.php dummyfile > foo";

where dummyfile is either empty or just contains the line

This is very odd. Any idea as to why I'm getting
this error?  


Site Timeline