您的位置:首页 > 其它

urlencode和rawurlencode的区别

2014-04-13 20:24 288 查看
urlencode和rawurlencode的区别

<?php
//urlencode和rawurlencode的区别

$str1 = urlencode(':/?= &#');
$str2 = rawurlencode(':/?= &#');
echo $str1."<br/>";
echo $str2."<br/>";
//die();

//唯一的不同是对空格的处理,urlencode处理成"+",rawurlencode处理成"%20"。

//urlencode使用方法:

$foo = "web 高级php程序员";
$bar = "shutdown -h now";

//urlencode只需对参数内容编码即可。
$query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar);

echo 'mycgi?' . htmlentities($query_string) . '';
//mycgi?foo=web+%E9%AB%98%E7%BA%A7php%E7%A8%8B%E5%BA%8F%E5%91%98&bar=shutdown+-h+now
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: