PHP中JavaScript的encodeURIcomponent
函数等价于什么?
最佳答案
试试 rawurlencode
.或者更准确地说:
function encodeURIComponent($str) {
$revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')');
return strtr(rawurlencode($str), $revert);
}
此功能完全有效how encodeURIComponent
is defined :
encodeURIComponent
escapes all characters except the following: alphabetic, decimal digits,-
_
.
!
~
*
'
(
)
关于php - PHP 中 JavaScript 的 encodeURIcomponent 等价物是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1734250/