比如地址是:a.php?u=test
这个a.php?u=test 后面的test是先经过base_encode('test'),假设是XXXXXX==,这里面后面是"==",再urlencode后传过去点击访问a.php?u=XXXX时
然后读取base_decode(u)时显示的后面会多一些乱码,像惦
打印u时,页面显示的是XXXXXX==,没错,但是看页面的源代码
后面的==,在源代码里是&#61;&#61;所以base_decode完会有点问题,不知道怎么解决。这里只是代表一部份,如果是回答替换一下的就不要回答,因为我知道哪些是应该要替换的。像 str_replace(array('\&quot;','&#61;','&#60;','&gt;'),array('"','=','<','>'),$a);
都是要替换的-。= 很郁闷

解决方案 »

  1.   


    rawurlencode();
    rawurldecode();base64_encode();
    base64_decode();
      

  2.   

    base64_decode()解密看恢复了没有?
      

  3.   

    把=号删掉就行了,base_decode可以正常解析的.
    =号只是为了补足base_encode后长度不足而加上的.
    如果一定要=号,那可以:
    1.替换成另一个字符
    2.urlencode和urldecode成对
    3.删掉=号后,base_decode时补回模4等于0的=号长度
      

  4.   

    用了base_encode 就不需要 urlencode (直接用这个就可以)
    2 选 1用base放在 URL 时删掉 ==
      

  5.   

    base64_encode像 str_replace(array('\&quot;','&#61;','&#60;','&gt;'),array('"','=',' <','>'),$a); 
    有专门的函数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 &quot;walk&quot; the &lt;b&gt;dog&lt;/b&gt; 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?>