admin管理员组文章数量:1356965
My variable with javascript looks like this:
var email = encodeURIComponent($('input[name=\'email\']').val())
email
is clearly being encoded and is producing this when sent to server: email%2540yahoo
What function in PHP will decode this value properly?
I've tried using html_entity_decode
My variable with javascript looks like this:
var email = encodeURIComponent($('input[name=\'email\']').val())
email
is clearly being encoded and is producing this when sent to server: email%2540yahoo.
What function in PHP will decode this value properly?
I've tried using html_entity_decode
- urldecode (x2) – Sjoerd Commented Jan 12, 2012 at 8:41
- The email is being urlencoded twice – im3r3k Commented Feb 2, 2016 at 20:16
4 Answers
Reset to default 5The correct url encoding for @ is %40.
When a url, for example from an e-mail, with the encoded @ character in it, is redirected using a rewrite rule, it will be rewritten as %2540 (the % is encoded as %25). If you keep rewriting / redirecting, you will replace % with %25 each time, ending up with %25252540 (or more 25, you get the picture).
For example clicking this:
http://example?email=info%40example
Will produce after a rewrite and redirect using a rewrite rule:
https://example?info%2540example
in the browser address bar, which does not correctly translate to [email protected] in php.
What function in PHP will decode this value properly?
You don't need to decode anything. $_GET["email"]
and $_POST["email"]
will work just fine. The encodeURIComponent
function is used to properly url encode a url to avoid having invalid urls. If you have a valid url, PHP will successfully be able to read the parameters.
echo urldecode(urldecode('email%2540yahoo.')); // [email protected]
Try urldecode(<value_to_decode_here>);
本文标签: javascriptWhat will decode quotemail2540yahoocomquot value in PHPStack Overflow
版权声明:本文标题:javascript - What will decode "email%2540yahoo.com" value in PHP? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743956686a2568257.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论