您的位置:首页 > 编程语言 > PHP开发

urldecode.php

2016-05-09 10:31 351 查看
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

 <head>

  <title> urldecode.php </title>

  <meta charset="UTF-8">

  <meta name="Author" content="">

  <meta name="Keywords" content="">

  <meta name="Description" content="">

 </head>

 <body>

<?php

//要配合提交页面一起使用

$a = explode('&', $QUERY_STRING);

$i = 0;

while ($i < count($a)) {

$b = @split('=', $a[$i]);

echo 'Value for parameter ', htmlspecialchars(urldecode($b[0])), ' is ', htmlspecialchars(urldecode($b[1])), "<br />\n";

$i++;

}

?>

 </body>

</html>

http://localhost/myphp/urldecode.php?foo=%E5%BC%A0%E4%B8%89

Value for parameter foo is 张三

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

 <head>

  <title> urldecode.php </title>

  <meta charset="UTF-8">

  <meta name="Author" content="">

  <meta name="Keywords" content="">

  <meta name="Description" content="">

 </head>

 <body>

<?php

//要配合提交页面一起使用

var_dump($QUERY_STRING);

$a = explode('&', $QUERY_STRING);

var_dump($a);

$i = 0;

while ($i < count($a)) {

$b = @split('=', $a[$i]);

echo 'Value for parameter ', htmlspecialchars(urldecode($b[0])), ' is ', htmlspecialchars(urldecode($b[1])), "<br />\n";

$i++;

}

?>

 </body>

</html>

http://localhost/myphp/urldecode.php?foo=%E5%BC%A0%E4%B8%89&barfoo=%E5%BC%A0%E4%B8%89

string 'foo=%E5%BC%A0%E4%B8%89&barfoo=%E5%BC%A0%E4%B8%89' (length=48)

array

  0 => string 'foo=%E5%BC%A0%E4%B8%89' (length=22)

  1 => string 'barfoo=%E5%BC%A0%E4%B8%89' (length=25)

Value for parameter foo is 张三

Value for parameter barfoo is 张三

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

 <head>

  <title> urldecode.php </title>

  <meta charset="UTF-8">

  <meta name="Author" content="">

  <meta name="Keywords" content="">

  <meta name="Description" content="">

 </head>

 <body>

<?php

//要配合提交页面一起使用

var_dump($QUERY_STRING);

$a = explode('&', $QUERY_STRING);

var_dump($a);

$i = 0;

while ($i < count($a)) {

$b = @split('=', $a[$i]);

echo 'Value for parameter ', $b[0], ' is ',$b[1], "<br />\n";

$i++;

}

?>

 </body>

</html>

string 'foo=%E5%BC%A0%E4%B8%89&barfoo=%E5%BC%A0%E4%B8%89' (length=48)

array

  0 => string 'foo=%E5%BC%A0%E4%B8%89' (length=22)

  1 => string 'barfoo=%E5%BC%A0%E4%B8%89' (length=25)

Value for parameter foo is %E5%BC%A0%E4%B8%89

Value for parameter barfoo is %E5%BC%A0%E4%B8%89
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: