<?php
$str = "this is a test";
echo urlencode($str);//this+is+a+test
echo "<hr/>";
$str = "urlencode.php?username=2+3%4 imooc&king # or \ 1=1 ";
echo urlencode($str);
//urlencode.php%3Fusername%3D2%2B3%254+imooc%26king+%23+or+%5C+1%3D1++
/**
* ? %3F
* = %3D
* 空格 +
* % %25
* & %26
* \ %5C
* + %2B
*/
echo "<hr/>";
echo urldecode(urlencode($str));
//urlencode.php?username=2+3%4 imooc&king # or \ 1=1
echo "<hr/>";
if (!empty($_GET)) {
print_r($_GET);
}
echo "<a href='test.php?username=imooc&king&age=2'>慕课网信息</a>";
//Array ( [username] => imooc [king] => [age] => 2 )
echo "<hr/>";
$username = "imooc&king";
$queryString = "username=" . urlencode($username) . "&age=2";
//地址栏 http://127.0.0.1/test.php?username=imooc%26king&age=2
echo "<a href='test.php?{$queryString}'>test</a>";
//Array ( [username] => imooc&king [age] => 2
echo "<hr/>";
$url = "https://www.baidu.com/s?wd=%E6%85%95%E8%AF%BE&ie=UTF-8&tn=90816750_hao_pg";
echo urldecode($url);//https://www.baidu.com/s?wd=慕课&ie=UTF-8&tn=90816750_hao_pg
echo "<hr/>";
echo urlencode("this is a test");//this+is+a+test
echo "<br/>";
echo rawurlencode("this is a test");//this%20is%20a%20test
echo "<hr/>";
echo urldecode("this+is+a+test");//this is a test
echo "<hr/>";
echo rawurldecode("this%20is%20a%20test");//this is a test
?>
[PHP加密]④--URL编码加密
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 在平时开发过程中经常会遇到PHP编码的URL需要被JS解析,JS编码的URL被PHP解析,平时自己有时候函数名也记...
- 一些工具方法,你可以写成Category,也可以直接复制过去当类方法,不用苦苦的去搜索了
- 常见编码加密解密的基础用法 Base64编码 URL编码 GZIP AES加密 DES加密 RSA加密 编码 加密工具类