开发者

How do web servers fill $_POST & $_GET?

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 se开发者_如何学运维rvers 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜