_GET/_POST vars passed to PHP how?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bush is a Fascist

    #1

    _GET/_POST vars passed to PHP how?

    Hi,

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

    Just curious.

    If environment variables, which ones?

    Thanks,
    333

  • Gordon Burditt

    #2
    Re: _GET/_POST vars passed to PHP how?

    >Are these passed by the webserver to PHP using[color=blue]
    >commandline arguments or by environment variable?[/color]

    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
    stdin.

    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

    Comment

    • Bush is a Fascist

      #3
      Re: _GET/_POST vars passed to PHP how?



      Gordon Burditt wrote:
      [color=blue]
      > 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
      > stdin.[/color]

      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_METHO D", "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
      "abc=123".

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

      Thanks,
      333

      Comment

      Working...