gpt4 book ai didi

php - $_SERVER ['QUERY_STRING' ] 在 CodeIgniter 中不起作用

转载 作者:行者123 更新时间:2023-12-04 19:39:28 28 4
gpt4 key购买 nike

在我的应用程序 url 之后?我无法访问完整的 URL
示例:www.examle.com/test.php?id=3通常我们可以得到像

$_GET['id'] = 3;
但在我的应用程序中它不起作用
所以我打印 $_SERVER 值。我的输出是
[UNIQUE_ID] => YjrrveqpEeuu1FcU9vhhAAAAAAQ
[HTTP_X_FORWARDED_FOR] => 122.179.51.122, 64.252.100.210
[HTTP_X_FORWARDED_PROTO] => https
[HTTP_X_FORWARDED_PORT] => 443
[HTTP_HOST] => www.example.com
[HTTP_X_AMZN_TRACE_ID] => Root=1-623aebbd-28269a532256d99658b3dceb
[HTTP_USER_AGENT] => Amazon CloudFront
[HTTP_X_AMZ_CF_ID] => vQJWRlfiiA4QWME7ScshqZmO4aR1nPvGjUKluZOfRK478BtFcIJ30w==
[HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
[HTTP_VIA] => 2.0 3d029316ef030de84eb214747e947124.cloudfront.net (CloudFront)
[HTTP_ACCEPT_ENCODING] => gzip, deflate, br
[HTTP_UPGRADE_INSECURE_REQUESTS] => 1
[HTTP_SEC_FETCH_SITE] => none
[HTTP_SEC_FETCH_MODE] => navigate
[HTTP_SEC_FETCH_USER] => ?1
[HTTP_SEC_FETCH_DEST] => document
[HTTP_SEC_CH_UA] => " Not A;Brand";v="99", "Chromium";v="99", "Google Chrome";v="99"
[HTTP_SEC_CH_UA_MOBILE] => ?0
[HTTP_SEC_CH_UA_PLATFORM] => "Windows"
[PATH] => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
[SERVER_SIGNATURE] =>
[SERVER_SOFTWARE] => Apache
[SERVER_NAME] => www.example.com
[SERVER_ADDR] => 172.31.67.87
[SERVER_PORT] => 80
[REMOTE_ADDR] => 172.31.23.129
[DOCUMENT_ROOT] => /var/www/html
[REQUEST_SCHEME] => http
[CONTEXT_PREFIX] =>
[CONTEXT_DOCUMENT_ROOT] => /var/www/html
[SERVER_ADMIN] => root@localhost
[SCRIPT_FILENAME] => /var/www/html/demo.php
[REMOTE_PORT] => 33234
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /demo.php
[SCRIPT_NAME] => /demo.php
[PHP_SELF] => /demo.php
[REQUEST_TIME_FLOAT] => 1648028605.456
[REQUEST_TIME] => 1648028605
这里也 [QUERY_STRING] => 是空的
但在另一个演示服务器中
[QUERY_STRING] => id=3
我可以知道主服务器不显示 query_string 的原因吗?
Application Version - CI 3
PHP version - 5.6
我也在使用 AWS centos 服务器

最佳答案

您可以启用查询字符串。

$this->config->set_item('enable_query_strings', TRUE);
实现此目的的一种简单方法是像这样解析服务器查询字符串。
$get_data = array();

parse_str($_SERVER['QUERY_STRING'], $get_data);
这会给你留下一个非常不安全的充满数据的数组,所以你应该使用 CI 的安全类来使其更安全;太喜欢了;
$get_data = $this->security->xss_clean($get_data);

关于php - $_SERVER ['QUERY_STRING' ] 在 CodeIgniter 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71585039/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com