标题: Email+URL的判断和自动转换函数
Roy723
中校
Rank: 1



UID 24409
精华 0
积分 1508
帖子 754
威望 0
金币 754
热心 0
阅读权限 50
注册 2006-7-25
状态 离线
Email+URL的判断和自动转换函数

<?php
function validateEmail($email)  
{     return eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $email);  
}  
function validateURL($url)  
{     return eregi("^((ht|f)tp://)((([a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3}))|(([0-9]{1,3}.){3}([0-9]{1,3})))((/|?)[a-z0-9~#%&"_+=:?.-]*)*)$", $url);  
}  
function convertURLS($text)  
{     $text = eregi_replace("((ht|f)tp://www.|www.)([a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})((/|?)[a-z0-9~#%&\/"_+=:?.-]*)*)", "http://www.\3", $text);  
    $text = eregi_replace("((ht|f)tp://)((([a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3}))|(([0-9]{1,3}.){3}([0-9]{1,3})))((/|?)[a-z0-9~#%&"_+=:?.-]*)*)", "<a href="\0">\0</a>", $text);  
    return $text;  
}  
function convertMail($text)  
{     $text = eregi_replace("([_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3}))", "<a href="mailto:\0">\0</a>", $text);  
    return $text;  
}  
function convertAllLinks($text)  
{     $text = convertURLS($text);  
    $text = convertMail($text);  
    return $text;  
}
?>  

顶部
[广告] 免费域名(Free Subdomain) 免费空间(Free hosting) PR查询(Google Pagerank)



当前时区 GMT+8, 现在时间是 2008-8-30 12:17
信产部ICP备案:京ICP备05066424号 北京市公安局网监备案:1101050648号

Powered by Discuz! 5.5.0
清除 Cookies - 联系我们 - 网友俱乐部 - Archiver - WAP