doqvzh345334 2014-03-12 01:10
浏览 76
已采纳

PHP FILTER_VALIDATE_EMAIL在不同的计算机上返回不同的值

I tested form validators for email field and inputted long email:

 $email = 'dfgjfdjglkdfjglkjdfgldfjglkdfjgkldfjlkgjdlkfjglkdfjkgdklfjgldkfjgldlfjgkldfjglkdfjglkdfklgjlkdfjkgkdfjlkgfjldkgkldjfgkljdfkgjlkdfgljdlf@mail.com';

On the local machine function filter_var return string with email:

 $email = 'dfgjfdjglkdfjglkjdfgldfjglkdfjgkldfjlkgjdlkfjglkdfjkgdklfjgldkfjgldlfjgkldfjglkdfjglkdfklgjlkdfjkgkdfjlkgfjldkgkldjfgkljdfkgjlkdfgljdlf@mail.com';

 die(var_dump(filter_var($email, FILTER_VALIDATE_EMAIL)));

But on the remote server this code returns FALSE.

PHP version on local machine - 5.3.2-1ubuntu4.22

On the remote machine - 5.3.28

Has filter_var function been changed between this version of PHP? Why I receive different values with the same code?

  • 写回答

2条回答 默认 最新

  • douchui4459 2014-03-12 01:18
    关注

    FILTER_VALIDATE_EMAIL has been updated a couple of times since 5.3.2 (you really should update your version BTW). The most notable update was this bug-fix causing a seg-fault when the input/address-to-validate was too long.
    Along side this fix (which is logged twice), Rasmus Lerdof on FILTER_VALIDATE_EMAIL returning false positives. Though, AFAIKT, this is not likely to be the cause of your woes.
    A couple of other changes include bugs involving special chars like ?, >1 and =.
    Anyway, to see all the changes since PHP5.3.2, just check the changelog on their website...

    Again: update your local version, it's getting rather dated. Given that you're running ubuntu:

    $ sudo apt-get install php5-dev
    //optionally
    $ sudo apt-get install php5-dev --install-suggests
    

    If you're running mint:

    $ sudo apt-get install php5-dev --install-recommends --install suggests
    

    on both distro's, preferably run sudo apt-get update first, of course...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部