Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP get函数未捕获参数_Php_Url_Get - Fatal编程技术网

PHP get函数未捕获参数

PHP get函数未捕获参数,php,url,get,Php,Url,Get,所以。。。我有以下非常简单的代码: <?php echo $_GET["base_grant_url"] ?> 参数打印正确。请注意,第一个参数中缺少“p”,第二个参数中缺少“.”字符。当传递以下两个URL时: http://localhost/?base_grant_url=http%3A%2F%2Fn00.test.com http://localhost/?base_grant_url=http%3A%2F%2Fn00. 这两个地址都不会打印回任何内容。。。我花了很长时间才

所以。。。我有以下非常简单的代码:

<?php echo $_GET["base_grant_url"] ?>
参数打印正确。请注意,第一个参数中缺少“p”,第二个参数中缺少“.”字符。当传递以下两个URL时:

http://localhost/?base_grant_url=http%3A%2F%2Fn00.test.com
http://localhost/?base_grant_url=http%3A%2F%2Fn00.
这两个地址都不会打印回任何内容。。。我花了很长时间才把问题缩小到这个范围,因为这只是一个更大场景的一小部分,但这正是我目前试图纠正的。为什么当参数不正确但其中包含HTTP和“.”字符时,我无法获取这些参数。。。$\u GET函数失败了吗?对于这个问题,我是否缺少一些常见的约定或一些简单的解决方法

编辑:所以在本地测试服务器上测试后,它可以正常工作。我将联系我的主机提供商,试图找到问题

至于打印输出。。。以下是代码和输出:

代码:

测试1(参数中的“否”)(如果http不在参数中,此选项也有效):

测试2(使用正确的URL):


我也有同样的问题,是我的网站托管公司在服务器上启用了一些mod安全规则,以防止他们所谓的“通用PHP代码注入”。我不确定我是否同意存在风险,但他们禁用了它,我的脚本开始工作。

对我来说工作正常,可能是一些严重的问题。它工作完美。。。获取基本url值没有问题…它工作正常。我希望您使用的是正确的URL。例如,如果您是在test.php中编写的,则使用
http://localhost/test.php?base_grant_url=htt%3A%2F%2Fn00.test.com
您是否有一个重写规则,该规则可能会删除可能存在危险的查询字符串,或者可能会防止注入?这不是空$\u GET的解决方案,但为什么您不使用类似base64_编码/解码?
http://localhost/?base_grant_url=http%3A%2F%2Fn00.test.com
http://localhost/?base_grant_url=http%3A%2F%2Fn00.
echo "Base Grant URL = ";
echo $_GET["base_grant_url"];
echo " -=- GET = ";
print_r($_GET); 
URL: http://testserver.com/?base_grant_url=https%3A%2F%2Fexamplecom%2Fsplash%2Flogin%2F%3Fmauth%3DABCDEFG123456
OUTPUT: Base Grant URL = https://examplecom/splash/login/?mauth=ABCDEFG123456 -=- GET = Array ( [base_grant_url] => https://examplecom/splash/login/?mauth=ABCDEFG123456 )
URL: http://testserver.com/?base_grant_url=https%3A%2F%2Fexample.com%2Fsplash%2Flogin%2F%3Fmauth%3DABCDEFG123456
OUTPUT: Base Grant URL = -=- GET = Array ( )