比如地址是:a.php?u=test
这个a.php?u=test 后面的test是先经过base_encode('test'),假设是XXXXXX==,这里面后面是"==",再urlencode后传过去点击访问a.php?u=XXXX时
然后读取base_decode(u)时显示的后面会多一些乱码,像惦
打印u时,页面显示的是XXXXXX==,没错,但是看页面的源代码
后面的==,在源代码里是==所以base_decode完会有点问题,不知道怎么解决。这里只是代表一部份,如果是回答替换一下的就不要回答,因为我知道哪些是应该要替换的。像 str_replace(array('\"','=','<','>'),array('"','=','<','>'),$a);
都是要替换的-。= 很郁闷
这个a.php?u=test 后面的test是先经过base_encode('test'),假设是XXXXXX==,这里面后面是"==",再urlencode后传过去点击访问a.php?u=XXXX时
然后读取base_decode(u)时显示的后面会多一些乱码,像惦
打印u时,页面显示的是XXXXXX==,没错,但是看页面的源代码
后面的==,在源代码里是==所以base_decode完会有点问题,不知道怎么解决。这里只是代表一部份,如果是回答替换一下的就不要回答,因为我知道哪些是应该要替换的。像 str_replace(array('\"','=','<','>'),array('"','=','<','>'),$a);
都是要替换的-。= 很郁闷
rawurlencode();
rawurldecode();base64_encode();
base64_decode();
=号只是为了补足base_encode后长度不足而加上的.
如果一定要=号,那可以:
1.替换成另一个字符
2.urlencode和urldecode成对
3.删掉=号后,base_decode时补回模4等于0的=号长度
2 选 1用base放在 URL 时删掉 ==
有专门的函数html_entity_decode
<?php
$orig = "I'll \"walk\" the <b>dog</b> now";$a = htmlentities($orig);$b = html_entity_decode($a);echo $a; // I'll "walk" the <b>dog</b> nowecho $b; // I'll "walk" the <b>dog</b> now
// For users prior to PHP 4.3.0 you may do this:
function unhtmlentities($string)
{
// replace numeric entities
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
$string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);
// replace literal entities
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}$c = unhtmlentities($a);echo $c; // I'll "walk" the <b>dog</b> now?>