Home > php教程 > php手册 > js/php的encodeURI

js/php的encodeURI

WBOY
Release: 2016-06-13 10:43:01
Original
1209 people have browsed it

encodeURI() 函数可把字符串作为 URI 进行编码,字符将被十六进制的转义序列进行替换。
decodeURI() 函数可对 encodeURI() 函数编码过的 URI 进行解码。

js的encodeURI()后的字符一般为utf-8编码,如果服务器端编码为不同编码,则需要iconv转换。
$a = urlencode(iconv("gb2312", "UTF-8", "电影")); //等同于javascript encodeURI("电影");
echo $a;
$b = iconv("utf-8","gb2312",urldecode("%E7%94%B5%E5%BD%B1")); //等同于javascript decodeURI("%E7%94%B5%E5%BD%B1");
echo $b;
?> 

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template