如何将查询字符串参数传递给PHP二进制文件? [英] How to pass query string parameters to the PHP binary?

查看:127
本文介绍了如何将查询字符串参数传递给PHP二进制文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个调用PHP二进制文件(通过CGI)处理脚本的网络服务器。

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

这就是问题所在:

PHP脚本没有获取命令行参数。例如,如果客户端请求 path / to / file.php?test = value ,那么 $ _ GET 数组是空白。

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.

我试过在环境变量( QUERY_STRING )中传递参数,但它们仍然没有显示。

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

如何将查询字符串参数传递给PHP应用程序?

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

推荐答案

PHP有各种SAPI。其中一个是cli SAPI,显然就是你正在使用的,cli SAPI不会填充$ _GET,$ _POST ...因为它是用于命令行脚本。

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.

在您的情况下,您需要PHP cgi SAPI。 (例如,你需要在你的shebang中用 php-cgi [1]替换 php

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

[1]在大多数发行版中,它被称为 php-cgi ,如果您自己编译PHP,则需要启用cgi。

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

这篇关于如何将查询字符串参数传递给PHP二进制文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆