urlencode()与urldecode() 详解

urlencode()编码:对字符串中除了 -_. 之外的所有非字母数字字符都将被替换成百分号(%)后跟两位 十六进制数 ,空格则编码为加号(+)。
urldecode()解码:还原 URL 编码字符串。
示例:
<?php
header("Content-Type:text/html; charset=utf-8");
//对参数值进行编码
$parm=urlencode("演示php-mysql");

//拼接url
$url="decode.php?par=".$parm;
?>

<a href="<?php echo $url;?>">urlencode演示</a>

点击连接后地址栏中汉字被编码了:

猜你喜欢

转载自blog.csdn.net/qq_35458793/article/details/72478921
今日推荐