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

如何将英文和数字urlencode

WBOY
WBOYOriginal
2016-06-23 14:14:051444browse

如果简单使用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;

Statement:
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