duanbi7204 2019-05-30 11:48
浏览 77

PHP urldecode()函数不适用于电子邮件验证

Im trying to decode the email, since its been encoded in the url, but the urldecode() function wont decode it.

I'v also tried rawurldecode(), then tried first encoding it myself and then decoding it, but its still encoded like %40 instead of an @ sign.

Here is the code:

$isValid = ! User::emailExists(urldecode($_GET['email']));

Im getting something like this:

http://localhost/account/validate-email?email=some_email%40gmail.com

  • 写回答

2条回答 默认 最新

  • doukui9491 2019-05-30 11:57
    关注

    I made a simple test:

    <?php
    $email = "some_email%40example.com";
    var_dump($email);
    var_dump(urldecode($email));
    var_dump(rawurldecode($email));
    

    The (expected) output is:

    string(24) "some_email%40example.com"

    string(22) "some_email@example.com"

    string(22) "some_email@example.com"

    So decoding works as expected.

    Could it be that you are looking at a single example where what you think is a %40 actually is something else, like a sequence that contains a unicode character that only looks like those you expect but actually is different?

    评论

报告相同问题?

悬赏问题

  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了