Home >Backend Development >PHP Tutorial > urlencode转义字符串的有关问题

urlencode转义字符串的有关问题

WBOY
WBOYOriginal
2016-06-13 13:47:08780browse

urlencode转义字符串的问题
a.php:

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
  $str = urlencode('张三');
  echo "<a href="b.php?name=%7B%24str%7D">查看</a>";



b.php:
PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
  $name = $_GET['name'];
  echo $name;



问题:
在a页面的源文件中查看超链接:查看
但点击超链接到b页面,却直接输出:张三
为什么反转义了?

谢谢!

------解决方案--------------------
是的。浏览器会自动帮你解码。用urldecode()解码也可。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn