How do web servers fill $

I am writing a Java web server and right now I am able to service .HTML files fine, but I am having a hard time figuring out how to handle .PHP files which require $_POST and $_GET.

How do web servers usually fill these arrays? There is no way to fill them using the command-line from what I can tell since I was originally thinking to pipe the stdout of an exec("php whatever.php some $_get args), but that's not possible without physically changing the php code to exploding the args and filling them into $_GET which I don't want to do -- I want to do it the way web servers do it.

Does anyone have suggestions of how web servers do things like this?


You can use interface with PHP via Common Gateway Interface (CGI), which boils down to setting up a bunch of environment variables and then invoking PHP.

REQUEST_METHOD="GET"
QUERY_STRING="param1=value1&param2=value2"

The CGI protocol is defined in RFC 3875.

链接地址: http://www.djcxy.com/p/60702.html

上一篇: Lua&Lighttpd

下一篇: Web服务器如何填充$