Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.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中的URL编码_Php_Html_Get_Urlencode_Urldecode - Fatal编程技术网

PHP中的URL编码

PHP中的URL编码,php,html,get,urlencode,urldecode,Php,Html,Get,Urlencode,Urldecode,我正在尝试查看提交表单时get参数的url编码是否可行。我在一些参考资料中看到,在动态构建url时使用url编码 ex: www.google.com?query=urlencode($query) 但是,如果我使用的是表单和提交按钮,那么如何应用url encode函数呢 <html> <body> <form action="send.php" method="get"> &

我正在尝试查看提交表单时get参数的url编码是否可行。我在一些参考资料中看到,在动态构建url时使用url编码

ex: www.google.com?query=urlencode($query)
但是,如果我使用的是表单和提交按钮,那么如何应用url encode函数呢

<html>
        <body>
                <form action="send.php" method="get">
                <input type="input" name="method" value="" />
                <input type="submit" name="submit" value="submit"/>
                </form>
        </body>
</html>


浏览器将为您对其进行URL编码。转到谷歌搜索“&”,你会在URL中看到“q=%26”。

浏览器会为你对它们进行URL编码。转到谷歌并搜索“&”,你会在URL中看到“q= % 26”。

< P>这是由浏览器完成的,如果你要求它做,考虑使用EnCype =“应用程序/X-WWW格式-URLNECODER”



注意,如果你不指定EnCyType,大多数现代浏览器都是默认的。

< P>这是由浏览器完成的,如果你要求它做的话,考虑使用EnCype =“应用程序/X-WWW格式-URLNECOND”



请注意,在大多数现代浏览器中,如果您甚至不指定enctype,默认情况下都会执行此操作。

如果我没有误解您的问题,为什么不使用urlencode()?在下面的注释中,您从未使用实际编码的字符(例如空格)进行测试。试试看。“application/x-www-form-urlencoded”是默认编码。您不能期望对整个查询部分(以“?”开头)进行编码,而只能对各个部分的值进行编码。请注意,urlencode和rawurlencode之间存在细微的(历史)差异。如果我没有误解您的问题,为什么不使用urlencode()?在下面的评论中,您从未使用实际编码的字符进行测试,例如空格。试试看。“application/x-www-form-urlencoded”是默认编码。您不能期望对整个查询部分(以“?”开头)进行编码,而只能对各个部分的值进行编码。请注意,urlencode和rawurlencode之间存在细微的(历史)差异。嘿,但我仍然能够看到我作为参数传递的内容。一切都没有改变。localhost/test.php?opt1=check_test&subt=subt,是我提交课程时得到的结果。你不会看到,对于你输入的内容,你会看到特殊字符,如&、#、/等等,其他字符完全没有改变,但是我仍然能够看到我作为参数传递的内容。一切都没有改变。localhost/test.php?opt1=check_test&subt=subt,是我提交课程时得到的结果。你不会看到,对于你输入的内容,你会看到特殊字符,如&、#、/等等,其他字符完全没有改变,但是我仍然能够看到我作为参数传递的内容。一切都没有改变。localhost/test.php?opt1=check_test&subt=subt是我提交它们时得到的结果,但我仍然能够看到我作为参数传递的内容。一切都没有改变。localhost/test.php?opt1=check\u test&subt=subt是我提交时得到的
<html>
        <body>
                <form action="send.php" method="get" enctype="application/x-www-form-urlencoded">
                <input type="input" name="method" value="" />
                <input type="submit" name="submit" value="submit"/>
                </form>
        </body>
</html>