Gum*_*mbo 126

试试rawurlencode.或者更确切地说:

function encodeURIComponent($str) {
    $revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')');
    return strtr(rawurlencode($str), $revert);
}
Run Code Online (Sandbox Code Playgroud)

此功能完全适用于如何encodeURIComponent定义:

encodeURIComponent 转义除以下字符外的所有字符:字母,十进制数字, - _ . ! ~ * ' ( )


roc*_*hal 6

你试过urlencode吗?

  • 是的。问题是它并不完全像 encodeURI,它转换每个字符,甚至 ^ 我想要一些功能完全相同的东西,而我不必干预 ^^。 (2认同)