且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP中的JavaScript的encodeURI组件相当于什么?

更新时间:2023-02-25 14:56:01

尝试 rawurlencode 。或更准确地说:

Try rawurlencode. Or to be more precise:

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

此功能正常工作如何定义 encodeURIComponent

This function works exactly how encodeURIComponent is defined:


encodeURIComponent 转义除以下内容之外的所有字符:字母,十进制数字, - _ * '

encodeURIComponent escapes all characters except the following: alphabetic, decimal digits, - _ . ! ~ * ' ( )