教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 PHP url中文编码cn_urlencode函数

PHP url中文编码cn_urlencode函数

发布时间:2016-10-26   编辑:jiaochengji.com
教程集为您提供PHP url中文编码cn,urlencode函数 等资源,欢迎您收藏本站,我们将为您提供最新的PHP url中文编码cn,urlencode函数 资源
PHP中对于URL进行编码,可以使用 urlencode() 或者rawurlencode(),二者的区别是前者把空格编码为 \' \',而后者把空格编码为 \' \',不过应该注意的是,在编码时应该只对部分URL编码,否则URL中的冒号和反斜杠也会被转义。下面是详细解释:

string urlencode ( string str)

返回字符串,此字符串中除了 -_. 之外的所有非字母数字字符都将被替换成百分号(%)后跟两位十六进制数,空格则编码为加号( )。


例子 1 :urlencode函数与rawurlencode函数区别

 

<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy1052')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy1052><?php
    $str='博 客';
    echo urlencode($str);
    echo "<br>";
    echo rawurlencode($str);
?>

url结果:

您可能感兴趣的文章:
PHP url中文编码cn_urlencode函数
php Curl抓取远程内容出现url中文编码问题的解决方法
php url编码与解码(加密/解密)
php 中require和include引用url和 php的文件编码转换函数问题
url链接中特殊字符转义方法
php url函数用法举例
php urlencode()函数实现URL编码解析
php获取搜索引擎入站关键词的函数
PHP如何使用urlencode()函数进行url编码?(代码示例)
php实现utf-8与gb2312的url编码转换

[关闭]
~ ~