Home > Backend Development > PHP Tutorial > 如何将英文和数字urlencode

如何将英文和数字urlencode

WBOY
Release: 2016-06-23 14:14:05
Original
1429 people have browsed it

如果简单使用urlencode

英文和数字并不会被编码而是直接跳过.

比如
'AAAAA 中文22222'
编码后
'AAAAA %D6%D0%CE%C422222'

实际上AAAAA我希望编码成
%41%41%41%41%41

22222
编码成
%32%32%32%32%32

之类的


回复讨论(解决方案)



高手哪里去了?

<?php// 源文件编码使用gbk$str = 'AAAAA中文22222';echo urlencode($str);$ret = '';for($i=0, $len=strlen($str);$i < $len; $i++) {	$ret .= '%'.strtoupper(dechex(ord($str[$i])));}echo "<br>";echo $ret;
Copy after login

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template