doqvzh345334 2014-03-12 09: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 09: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条)

报告相同问题?

悬赏问题

  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址
  • ¥15 elmos524.33 eeprom的读写问题
  • ¥15 使用Java milo连接Kepserver服务端报错?
  • ¥15 用ADS设计一款的射频功率放大器
  • ¥15 怎么求交点连线的理论解?
  • ¥20 软件开发方法学习来了
  • ¥15 微信小程序商城如何实现多商户收款 平台分润抽成
  • ¥15 HC32L176调试了一个通过TIMER5+DMA驱动WS2812B
  • ¥15 cocos的js代码调用wx.createUseInfoButton问题!