Validating an Email Address With Zend Framework
来源:互联网 发布:四川成都大学淘宝地址 编辑:程序博客网 时间:2024/05/16 06:50
Email addresses are one of trickiest input types to validate because there are multiple ways emails can be written according to the RFC2822 specification. You could have me@gmail.com, or me+spam@gmail.com, or “mark@server”@marksanborn.net, common on Linux/BSD systems.
A lot of times people will use a regular expression like:
(/w+@[a-zA-Z_]+?/.[a-zA-Z]{2,6})
This regular expression would work for almost all email addresses but would fail for others. For example mark@gmail.co.uk would not match. Either would mark+spam@gmail.com. Which by the way is a very useful feature for email hosts that support it.
Fortunately using my favorite PHP Framework, Zend Framework, we don’t have to reinvent the proverbial wheel.
Validating an Email Address with Zend Framework
$validator = new Zend_Validate_EmailAddress();if ($validator->isValid($email)) { // email appears to be valid} else { // email is invalid; print the reasons foreach ($validator->getMessages() as $message) { echo "$message/n"; }}
Although they managed to get the regex for validating emails correctly, this is not where the power of Zend lies. Zend gives you the ability to:
- Check if the hostname actually accepts email
- Configure which emails types you will accept
- Validate Top Level Domains
- Validate International Domains Names (for international characters)
- Validating an Email Address With Zend Framework
- svnmanager:You entered an invalid email address.
- Validate Email Address With Regular Expression
- Using Zend Framework with CodeIgniter
- INTEGRATING SMARTY WITH THE ZEND FRAMEWORK
- Integrating Smarty with the Zend Framework
- Integrating Smarty with the Zend Framework Travello_View_Smarty
- Integrating Smarty with the Zend Framework
- Using Zend Framework with Mutil Database
- Sending Emails with the Zend Framework
- WITH ROLLUP在zend framework中的写法
- PHP Accelerators : APC vs Zend vs XCache with Zend Framework
- Creating an Ext JS grid using the Zend Framework
- INTEGRATING SMARTY AND EZCOMPONENTS WITH THE ZEND FRAMEWORK
- Integrating Smarty and ez Components with the Zend Framework
- This email address is not valid for use as an Apple ID.
- 解决:Cannot push these commits as they contain an email address marked as private on GitHub
- zend framework
- 关于Zend ID的生成方法
- cuda 开发环境搭建
- 在WSS里面使用Session
- SVN客户端安装与使用
- Ajax技术实现三级联动下拉框
- Validating an Email Address With Zend Framework
- tcpdump抓包分析TCP三次握手过程
- UTF8ToAnsi 和 AnsiToUTF8
- 鞍山出差2工作计划(2010年10月09日星期六)
- VBS 写XML 文件
- rindex函数
- 如何在WSS中使用Microsoft Enterprise Library
- 数据连接池配置文件
- 如何自动截获输出到打印机的文本数据(转载)